I have an api, which when tested on my localhost works fine, but on the server where I call it in the published one, I get the error:
The SSL connection could not be established, see inner exception
In inner exception:
System.Security.Authentication.AuthenticationException: Authentication failed because the remote party sent a TLS alert: ‘HandshakeFailure’.rn —> System.ComponentModel.Win32Exception (0x80090326): Mensaje recibido inesperado, o bien su formato es incorrecto.rn — End of inner exception stack trace —rn at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)rn at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
The code in the following controller:
[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();
}
It falls into the PostAsync line. I would like if someone could help me or indicate how to solve it. Thank you in advance.