Monday, March 12, 2007

Accessing web services over https using own-made certificate

In most of our products we are extensively using web-services. Some of them are relaying on SSL to encrypt data streams. It works pretty good from the .NET Framework client if corresponding server certificate is issued by certification authority known by Windows, but if you want some $$ in your budget, you probably will generate the certificate by yourself. When you are trying to access such service from C# program, you will get "The underlying connection was closed: could not establish trust relationship for SSL/TLS secure channel". There is a good post about how to make it work by Jan Tielens, but for .NET Framework 2.0 there is even simpler solution - put the line below somewhere during initialization of your application

System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate { return true; };

1 comment:

Salene said...

Good post.