0

I have the tool which consumes a web service. I have generated a self signed cert for the web service, exported it using certificate manager to a local path.

I'm following the following msdn code to add the certificate into by webservice. https://support.microsoft.com/en-us/kb/901183

string certPath = @"C:\TestData\certificate.cer";
test.ClientCertificates.Add(X509Certificate.CreateFromCertFile(certPath));

Above is my code.

I'm getting the following error.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Stack trace:

at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at web_Client.testClient.testClassWebService.Add(Request request) in  C:\Workspace\Reference.cs:line 248
at web_Client.WebClient.Add() in C:\Workspace\WebClient.cs:line 227

I have no idea what's going on. I'm very new to web and certificates. Please help.

Ekta
  • 338
  • 2
  • 9
  • 26

1 Answers1

0

I encountered this over the past couple of days with an application that was working fine before. I think the people that own the server updated something and now they require a different protocol. I solved one of the problems just by moving to a later framework version. For the second one I had to move to the later version (4.5) and set ServicePointManager.SecurityProtocol to a different protocol. You can use intellisense to see your options.

Lorek
  • 855
  • 5
  • 11