We have an application that calls out to a Government web services to pulls data into our system. They have eliminating “weak ciphers” and now only support three. I am getting some errors that the system can't create a secure channel. Is there something else I need to do for this to work?
Error
An exception has been thrown: (System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
Code
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Ssl3 |
SecurityProtocolType.Tls |
SecurityProtocolType.Tls12;
Service Code
private T Run<T>(string url, string queryString) where T : new()
{
T result = default(T);
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
using (HttpResponseMessage response = client.GetAsync(queryString).Result)
{
if (response.IsSuccessStatusCode)
{
result = response.Content.ReadAsAsync<T>().Result;
}
else
{
throw new Exception($"Resourse {url}{queryString} failed: {(int)response.StatusCode} ({response.ReasonPhrase})");
}
}
}
return result;
}
Currently supported ciphers:
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256