Search code examples
.netx509certificate2

How to get X509Certificate from an arbitrary HTTPS URL?


I'm using HttpWebRequest to pull a page from an arbitrary HTTPS URL. In addition to the actual page result, I want to get an X509Certificate2 instance for the remote server I just talked to. I'm sure the public certificate is on the computer somewhere because its chain had to be validated as part of the request. How can I get access to it?

Also, how can I make sure that the ciphersuite used in the SSL channel isn't simply the null ciphersuite? I need to make sure that decent encryption is actually occurring.


Solution

  • Oh! (duh)

    HttpWebRequest.ServicePoint.Certificate
    

    But this doesn't answer the ciphersuite part of the question, so that's still open if anyone can answer it. :)