Pinu
Pinu

Reputation: 7520

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

I am trying to consume a webservice and it is giving throwing this error.

Upvotes: 1

Views: 2312

Answers (2)

Now Coding
Now Coding

Reputation: 5

This is a certificate related error. Whenener we hit a secure URL in web browser, the browser will ask for permission with some warnings like "the certificates are not trusted, click to continue etc"

But when we consume the a secure webservice URL in code nothing like that happens.

But we have a solution to this problem.For this we need to create a class inheriting ICertificatePolicy interface.

This thing is properly explained and solution code available on this link Click to See

Upvotes: 0

Steve Gilham
Steve Gilham

Reputation: 11277

When I've had errors like that they were due to either not having the service host name matching the one in the certificate it presents, or, less often, not having the appropriate certificate chain on the client to verify the server's certificate.

I would check the name you are contacting the service by and what the certificate it sends say -- you can watch the SSL negotiation with WireShark or similar, and see the strings in the second server packet.

Upvotes: 1

Related Questions