Tengo una api, que al probarla en mi localhost funciona bien, pero en el servidor de donde lo llamo en el publicado, me sale el error: The SSL connection could not be established, see inner exception EL codigo en el controller siguiente:
[HttpGet]
[Route("obtienerespuesta")]
public async Task<List<ResponsePymeModels>> InboundTransfersItauPyme(string api_key, string AccountLink, string AccountNumber, string urlbanco, string BookingDate)
{
var serviceCollection = new ServiceCollection();
Configuere(serviceCollection);
var servicios = serviceCollection.BuildServiceProvider();
var httpClientFactory = servicios.GetRequiredService<IHttpClientFactory>();
var client = httpClientFactory.CreateClient();
client.Timeout = TimeSpan.FromMinutes(230);
client.DefaultRequestHeaders.Add("x-api-key", api_key);
var json = new JObject(
new JProperty("RequestData",
new JObject(
new JProperty("AccountCredential",
new JObject(
new JProperty("AccountLink", AccountLink)
)
),
new JProperty("AccountNumber", AccountNumber),
new JProperty("BookingDate", BookingDate),
new JProperty("Currency", "CLP")
)
)
);
var postData = new StringContent(json.ToString(), Encoding.UTF8, "application/json");
var request = await client.PostAsync(urlbanco, postData);//aki se cae
var response = await request.Content.ReadAsStringAsync();
}
private static void Configuere(ServiceCollection services)
{
services.AddHttpClient();
}
En el inner exception dice:
System.Security.Authentication.AuthenticationException: Authentication failed because the remote party sent a TLS alert: 'HandshakeFailure'.\r\n ---> System.ComponentModel.Win32Exception (0x80090326): Mensaje recibido inesperado, o bien su formato es incorrecto.\r\n --- End of inner exception stack trace ---\r\n at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)\r\n at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
Se cae en la linea PostAsync. Me gustaría si alguien pudiera ayudarme o indicar como darle solucióon. Desde ya, gracias.