Support Certificates In Your Apps with the .NET Framework 2.0
SSL Support
The SSL authentication protocol relies on certificates. Support for SSL in the .NET Framework consists of two parts. The special (but most widely used) case of SSL over HTTP is implemented by the HttpWebRequest class (this is also ultimately used for Web service client proxies). To enable SSL, you don't have to do anything special besides specify a URL that uses the https: protocol.
When connecting to an SSL secured endpoint, the server certificate is validated on the client. If validation fails, by default the connection is immediately closed. You can override this behavior by providing a callback to a class called ServicePointManager. Whenever the HTTP client stack does certificate validation, it first checks if a callback is provided-if that's the case, it executes your code. To hook up the callback, you have to provide a delegate of type RemoteCertificateValidationCallback: Copy Code // override default certificate policy
// (for example, for testing purposes)
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(VerifyServerCertificate);
No comments:
Post a Comment