TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Calling a Web Service Over SSL - Jumping a Small Hurdle

Ever want to call a Web Service on a Web site that pops up one of these dialog boxes because of a certificate problem?

Well, it turns out to be quite simple if you don't mind a small hack. :-)

public static void TestSSL() {

    //--> https://someURL/service1.asmx

    Service1 service = new Service1();

 

    ServicePointManager.CertificatePolicy = new OpenSSLPolicy();

    string s = service.HelloWorld();

    //call the web service

    Console.WriteLine(s);

}

 

 

public class OpenSSLPolicy : ICertificatePolicy {

    public bool CheckValidationResult(ServicePoint srvPoint,
                                      X509Certificate certificate,
                                      WebRequest request,
                                      int certificateProblem) {

        return true;

    }

}


Digg!

posted on Monday, June 27, 2005 2:27 PM

Feedback

No comments posted yet.