net mvc form example crear asp .net asp.net-mvc twitter twitter-oauth owin

.net - form - security asp net mvc



Inicio de sesión de Owin en Twitter: el certificado remoto no es válido según el procedimiento de validación (7)

Empecé a recibir este error recientemente al intentar iniciar sesión con Twitter. ¿Alguna idea de por qué?

Stack Trace: [AuthenticationException: The remote certificate is invalid according to the validation procedure.] System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) +230 System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) +13 System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) +123 [WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.] System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +6432446 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) +64


El valor de Servidor de alta seguridad DigiCert SHA2 C A "5168FF90AF0207753CCCD9656462A212B859723B" no parece ser válido. El nuevo valor es "01C3968ACDBD57AE7DFAFF9552311608CF23A9F9". Es válido del 28/6/2016 al 19/09/2019. Lo encontré yendo a https://api.twitter.com/ en Chrome, luego haciendo clic en el candado en la barra de direcciones para ver el certificado.


Gracias al poder del código abierto, podemos ver que las huellas dactilares de los certificados de Twitter se han codificado en el Proyecto Katana.

Microsoft.Owin.Security.Twitter.TwitterAuthenticationOptions

Recientemente algunos certificados deben haber cambiado y ahora las huellas dactilares ya no coinciden.

Agregue una nueva huella digital para el certificado "VeriSign Class 3 Public Primary Certification Authority - G5" a sus Opciones de autenticación de Twitter en su Startup.Auth.cs (para usuarios de MVC).

Cambiar desde el predeterminado:

app.UseTwitterAuthentication( consumerKey: "XXXX", consumerSecret: "XXX" );

Utilizar esta:

app.UseTwitterAuthentication(new TwitterAuthenticationOptions { ConsumerKey = "XXXX", ConsumerSecret = "XXXX", BackchannelCertificateValidator = new CertificateSubjectKeyIdentifierValidator(new[] { "A5EF0B11CEC04103A34A659048B21CE0572D7D47", // VeriSign Class 3 Secure Server CA - G2 "0D445C165344C1827E1D20AB25F40163D8BE79A5", // VeriSign Class 3 Secure Server CA - G3 "7FD365A7C2DDECBBF03009F34339FA02AF333133", // VeriSign Class 3 Public Primary Certification Authority - G5 "39A55D933676616E73A761DFA16A7E59CDE66FAD", // Symantec Class 3 Secure Server CA - G4 "5168FF90AF0207753CCCD9656462A212B859723B", //DigiCert SHA2 High Assurance Server C‎A "B13EC36903F8BF4701D498261A0802EF63642BC3" //DigiCert High Assurance EV Root CA }) });


Para fines de prueba solamente (!) También es posible configurar el

options.BackchannelCertificateValidator = null;

y agregue a su Global.asax Application_Start:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };


Para mí, solo se actualizó Microsoft.Owin.Security.Twitter a la versión 3.1.0, ¡incluso sin agregar las huellas digitales!


Para resumir y salvar a las personas que cavan a través de los comentarios, aquí la última configuración:

app.UseTwitterAuthentication(new TwitterAuthenticationOptions { ConsumerKey = "XXXX", ConsumerSecret = "XXXX", BackchannelCertificateValidator = new Microsoft.Owin.Security.CertificateSubjectKeyIdentifierValidator(new[] { "A5EF0B11CEC04103A34A659048B21CE0572D7D47", // VeriSign Class 3 Secure Server CA - G2 "0D445C165344C1827E1D20AB25F40163D8BE79A5", // VeriSign Class 3 Secure Server CA - G3 "7FD365A7C2DDECBBF03009F34339FA02AF333133", // VeriSign Class 3 Public Primary Certification Authority - G5 "39A55D933676616E73A761DFA16A7E59CDE66FAD", // Symantec Class 3 Secure Server CA - G4 "‎add53f6680fe66e383cbac3e60922e3b4c412bed", // Symantec Class 3 EV SSL CA - G3 "4eb6d578499b1ccf5f581ead56be3d9b6744a5e5", // VeriSign Class 3 Primary CA - G5 "5168FF90AF0207753CCCD9656462A212B859723B", // DigiCert SHA2 High Assurance Server C‎A "B13EC36903F8BF4701D498261A0802EF63642BC3" // DigiCert High Assurance EV Root CA }) });

Todos los créditos a @MichaelLake y @KennethIto.


Tuve este problema exacto. Seguí la publicación anterior y obtuve el error 401 (no autorizado) mencionado en otro comentario.

Fui a mi cuenta de desarrollador de Twitter y desmarqué un cuadro titulado: "Habilitar bloqueo de devolución de llamada". Haga clic en guardar, presione F5 y funcionó.

Entonces el código anterior funcionó para mí. Si obtiene un doble 401, verifique su cuenta de Twitter para la casilla de verificación.


Desactiva Fiddler.

De alguna manera, el depurador web Fiddler arruina el Oauth para Twitter.