2015-06-01 5 views
6

Próbujemy połączyć się z api facebook z aplikacji asp .net MVC 4.6 za pomocą standardowego zapytania internetowego. Wszystko działa dobrze na wszystkich oprócz jednego z naszych serwerów. Serwer, o którym mowa, działa w systemie Windows 2012 i IIS 8.Co może spowodować wyjątek "Nieobsługiwany algorytm klucza certyfikatu" na żądanie internetowym GET

Na tym konkretnym serwerze otrzymujemy następujący wyjątek podczas uruchamiania żądania webowego GET na Facebooku.

The certificate key algorithm is not supported.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The certificate key algorithm is not supported.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NotSupportedException: The 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 on a send.]
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

Kod wygląda następująco:

// 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; 
      } 
     } 
    } 

Jesteśmy drapania głowy, dlaczego to działa na wszystkich, ale jeden z naszych serwerów.

Czy ktoś ma jakieś pomysły, co może powodować ten błąd i jak go rozwiązać.

Dzięki.

+0

Wygląda na to, że dzieje się tak tylko wtedy, gdy strona używa ECC (kryptografii krzywych eliptycznych) w swoim certyfikacie. – herostwist

Odpowiedz

6

Udało mi się powielić problem i wygląda na to, że jest to błąd w śledzeniu sieci, który powoduje ustawienie X509Certificate2.ToString (true), który stażysta zgłasza wyjątek.

Jedyne rozwiązanie, jakie znalazłem, to usunięcie całej sekcji "System.Dianositics", która wyłączy rejestrowanie.

+1

Dzięki, zawęziliśmy to do usunięcia herostwist

+2

Bizzare. Wyłączyłem logi i wyjątek zniknął ... Co za wspaniałe BCL :) –

+0

Które dokładnie logi usunąłeś i gdzie? –

Powiązane problemy