6

I am using BasicHttpBinding to connect a web service hosted on a secured (https) port. To get it working, I have changed the Security.Mode to TransportWithMessageCredential and Security.Message to BasicHttpMessageCredentialType.Cerificate. I am also calling

client.ClientCredentials.ClientCertificate.SetCertificate()

with localhost as the subject name.

The issue here is that for unit testing, I have an unsigned certificate from the web server and am supposed to ignore any certificate error thrown during the proxy creation; but I am unable to do so, because I keep getting an error telling me to "specify a certificate". Right now, I am clueless; I appreciate any help here.

2
  • If you are only using server certificate, then set the SecurityMode to Transport
    – Tung
    Apr 21, 2012 at 5:36
  • Thanks @Tung; I could get RemoteCertificateValidationCallback method called and able to return 'TRUE' to ignore the errors! Please write your comment as an answer! Apr 21, 2012 at 8:59

2 Answers 2

9

You can use the following code to skip certificate validation. This creates a RemoteCertificateValidationCallback that always return true for any certificate.

System.Net.ServicePointManager.ServerCertificateValidationCallback = 
    (sender, certificate, chain, errors) => true;
1
  • 1
    I already had the ServerCertificateValidationCallback but was not getting called; once I changed the Security Mode to Transport, it worked! Apr 21, 2012 at 10:04
6

For server ssl, the SecurityMode should be set to Transport.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.