views:

283

answers:

1

Hello,

I have a client program written in .NET 2.0, that connects to the web service. I used Visual Studio to generate a class derived from SoapHttpClientProtocol, every method was generated just fine, everything is working.

But - the web service is running only through HTTPS, so I was just wondering, how could I get an X509Certificate instance of the server's certificate.

I know the Framework does the validation of the server's certificate transparently, so I dont need to care of the certificate validation in my code, but I what if I needed to read the certificate's serial number?

The SoapHttpClientProtocol base class seems to have only members/methods for client certificates.

Thanks for help

+2  A: 

You hook into the ServicePointManager.ServerCertificateValidationCallback. Your callback will be invoked with the server's X509Certificate and you can check anything you like on it, like the Issuer and SerialNumber.

Remus Rusanu