The underlying connection was closed. Could not
establish trust relationship for the SSL/TLS secure channel.
In this article we will be seeing how to resolve the following issue "The
underlying connection was closed. Could not establish trust relationship for the
SSL/TLS secure channel".
I was trying to create Visual Web Part in SharePoint 2010 using Visual Studio
2010 in which I need to access the HTTPS listdata.svc web service. When I was
trying to access the https web service I was getting the following error
"The underlying connection was closed. Could not establish trust relationship
for the SSL/TLS secure channel".
How to resolve:
Since we are trying to access the HTTPS web service we need to add the SSL to
the SharePoint Trusted Root Authority.
Export an SSL certificate from windows server:
- Go to Start => Run => Type MMC and then click on Ok.
- In Microsoft Management Console, Click on the File menu and then click on Add\Remove Snap-in...
- In the Add or Remove Snap-ins wizard, select Certificates from the available snap-ins and then click on Add.
- Select My user account and click on Finish.
- Certificate will be added and click on Ok.
- In the left pane expand Certificates, and then expand Personal.
- Click on Certificates folder.
- Right click on the certificate, click on All Tasks and then click on Export.
- Certificate Export Wizard will pop up, click on Next.
- In the Export File Format select DER encoded binary X.509 (.CER) format.
- Click on Next.
- In the File to Export click on browse, select the location and enter the Name.
- Click on Save, the certificate will be saved.
- In the Certificate Export Wizard, click on Finish.
- You will be getting the following pop up, click on Ok.
- The certificate is exported successfully.
Add the SSL Certificate into SharePoint
Trusted Root Certificate authority:
- Go to Central Administration =>Security =>Manage Trust.
- In the ribbon interface, go to Trust Relationships Tab =>Manage group =>Click on New button.
- In the Root Certificate to trust relationship section, click on Browse.
- Select the certificate that we have exported.
- Click on Ok.
- Certificate is imported to the SharePoint Trusted root Authority.
I was able to access the HTTPS web service
successfully after adding the SSL certificate to the Trusted Root Authority.