views:

164

answers:

2

Hi All,

I have an ASP.NET website that is contacting a webservice. Everything works fine connecting via http but when I try https:// it can't connect. I don't seem to get any error from the website and the webservice logs show nothing, meaning nothing has connected to it.

I can connect to my https:// webservice from a site like soapclient.com and request information, so the webservice and ports are working.

Is there anything special I should be doing in order to connect to a https:// webservice over a normal http:// one in .NET? All I am doing at the moment is changing the URL it is connecting to to my secure one instead.

I am using ASP.NET 2, IIS7

Thanks in advance.

EDIT: Just found the actual error message: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel - Which in my eyes tells me I haven't added my self signed certificate to the installed certs on the server ... but I have ...

A: 

It looks like your client encounters a certificate validation error, because your server certificate is self-signed.

Try including the following line (C#) in your web site code, before calling the web service. This will tell .NET to ignore all certificate validation errors:

ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { return true; };

This should obviously not be used in a production environment :)

Eric Eijkelenboom
+1  A: 

You need to add your self-signed certificate under Trusted Root Certificate Authorities in the Local Computer store of the server running the ASP.NET website.

Export the certificate from the webservice server as a .cer file, and copy it to the server running the ASP.NET website. Then, on that server:

  1. Double-click the .cer file and Install Certificate
  2. In the wizard, choose the store as the Local Computer folder under Trusted Root Certificate Authorities.
  3. You might have to restart IIS, or the server

There are some good instructions towards the bottom of this page, under "Installing the self-signed certificate on client computers": http://webhelp.esri.com/arcgisserver/9.3/dotNET/index.htm#setting_up_ssl.htm

Joe Daley
Thanks. This seemed to sort the issue. I did install the certificate via IE by clicking on it and choosing install, I even chose the location you have mentioned as I know it should be there but for some reason it didn't install it. Does .NET look somewhere different to the place IE does because I could view the web service with no problems in IE?
webnoob
IE and .NET both use the Windows certificate stores. Not sure... maybe it did work and you just needed to restart things?
Joe Daley
I did the restart before adding the cert in. I guess it's just one of those bizarre things ... Thanks again for the help.
webnoob