Search code examples
c#ssliisvisual-studio-2013administrator

VisualStudio:Could not create SSL/TLS secure channel


I have searched for this alot but couldn't find this specific problem related answer.

I am accessing a web service trough my c# web application. The web service require a certificate in the request to authenticate.

The web application is in development mode and I am using VisualStudio 2013 with iis express.

I have installed the client certificate in the local machine via MMC. In the web service request I added the X509Certificate. The web server doesn't support SSL but TLS so I am adding the following line as well:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

I am also adding the following line:

ServicePointManager.ServerCertificateValidationCallback =delegate { return true; };

The problem is if I am running the VisualStudio as normal user with iis express i get

"The request was aborted: Could not create SSL/TLS secure channel."

But if I run the VisualStudio as administrator with iis express then the connection is successful and the webserver return the desired response.

Then I hosted the application in my local iis with .Net full trust but still got the:

"The request was aborted: Could not create SSL/TLS secure channel."

My ip is white listed on the web server.

If someone can help me out to understand why does it work when the VisualStudio is being run as an administrator and why doesn't it work as a normal user ?


Solution

  • Just a guess: This maybe a certificate access error.

    You can edit the ACL of the certificate: Select the certificate in the MMC; context menu; all tasks; manage private keys.

    The administrators are in this list by default. This matches with the behavior you describe.