Home

Allowing untrusted certificates for assembly/web.config connection

How can I specify that an assembly/web.config based connection should allow untrusted certificates? I get this error when trying to connect to a server that has a certificate that isn't trusted:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)

Comments

  • What sort of connection is it?
  • I am not sure what you mean about trusting an assembly or web.config based connection - but if you are getting SSL provider errors you can try using the following one-liner to accept all SSL certificates that the WebClient and other HTTP classes/methods use. It will need to run before any network calls are made.

    System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender,cert,chain,errors) => { return true; };

    Note: this would be a bad thing in production. You are better off solving the issue of importing the correct certificates so things just work, or at least inspecting the certificates in your callback and matching them against a known good copy.
Sign In or Register to comment.