I’m trying to make an SSL call using HTTPWebRequest and its continually failing saying it can’t establish trust. I’ve added a callback to ServicePointManager.ServerCertificateValidationCallback and returning true always works. However, I’d like things to be a little more secure than that. Looking at the SslPolicyErrors in the validation method it appears that I’m getting a RemoteCertificateNameMismatch error. What isn’t matching up correctly to cause this kind of error?
(edit: see comments in the answer) The site I’m accessing uses HTTPBasic over SSL and an URL something like v1.api.serviceprovider.com, with a certificate issued to *.serviceprovider.com.
General certificate issues:
This specific error usually means that the certificate isn’t issued for the site you are hitting. Examples:
Most of these are readily identifiable by navigating to the site and reading the warnings that your browser gives you, and inspecting the certificate that got issued.