We are trying to connect to facebook api from an asp.net MVC 4.6 application using a standard web request. Everything works fine on everyone except one of our servers. The server in question launches windows 2012 and IIS 8.
On this particular server, we get the following exception when running the GET web request on facebook.
The certificate key algorithm is not supported.
Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for error information and where it originated in the code.
Exception Details: System.NotSupportedException: The certificate key algorithm is not supported.
Source Error:
An unhandled exception was thrown during the execution of the current web request. Information about the origin and location of the exception can be identified using the exception stack trace below.
Stack trace:
[NotSupportedException: Certificate key algorithm is not supported.] System.Net.TlsStream.EndWrite (IAsyncResult asyncResult) +409 System.Net.ConnectStream.WriteHeadersCallback (IAsyncResult ar) +213
[WebException: The underlying connection was closed: An unexpected error occurred while sending.]
System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) +894 System.Net.Http.HttpClientHandler.GetResponseCallback (IAsyncResult ar) +92
[HttpRequestException: An error occurred while sending the request.]
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () +32
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task) +96 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult () +49
The code is as follows:
// Request private static async Task<T> Request<T>(string url) where T : class { using (var handler = new WebRequestHandler()) { handler.ServerCertificateValidationCallback = delegate { return true; }; using (var client = new HttpClient(handler) { Timeout = System.TimeSpan.FromSeconds(20) }) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var result = await client.GetAsync(url); if (result == null) return null; var model = await result.Content.ReadAsAsync<T>(); return model; } } }
We scratch our heads why this works on all but one of our servers.
Does anyone have any ideas what might cause this error and how to solve it.
Thanks.
source share