This is a problem if you try to use Azure Mobile Services - because https connections to a service like https://mydemoservice.azure-mobile.net will result in an AggregateException within which (several layers deep) will be a MobileServiceInvalidOperationException with a message saying just 'Send Failure' (derived from ServiceFilterResponseStatus SendFailure)
If anyone else encounters this issue... then below is some hacky code I transplanted from an old demo project. It seems to work.... but could probably be improved to work with just Microsoft Secure Server Authority messages.
This code hacks the ServicePointManager to allow it to accept all HTTPS/SSL addresses regardless of whether or not the certificate is trusted. Don't use this in your banking apps please :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this code is a workaround for: | |
// "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." | |
// - this error caused by Nike not having a valid certificate now! | |
ServicePointManager.ServerCertificateValidationCallback = delegate | |
(object sender, | |
System.Security.Cryptography.X509Certificates.X509Certificate pCertificate, | |
System.Security.Cryptography.X509Certificates.X509Chain pChain, | |
System.Net.Security.SslPolicyErrors pSSLPolicyErrors) | |
{ | |
//if (pSSLPolicyErrors == System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch && pCertificate.Issuer == "CN=Entrust Certification Authority - L1C, OU=\"(c) 2009 Entrust, Inc.\", OU=www.entrust.net/rpa is incorporated by reference, O=\"Entrust, Inc.\", C=US") | |
{ | |
return true; | |
} | |
//if (pSSLPolicyErrors == System.Net.Security.SslPolicyErrors.None) | |
// return true; | |
//return false; | |
}; |
No comments:
Post a Comment