Could not create SSL/TLS secure channel - Fixed


I am accessing a 3rd party client WCF secured web service using a client certificate issued by them. I have added this client certificate to my servers' certificate store. (Ref#1 (packing a certificate), Ref#2 (importing to store))

And I have the client WCF configuration as follows:

      <binding name="GoogleServiceSoapBinding">
       <security mode="Transport">
        <transport clientCredentialType="Certificate" />
      <binding name="ProvisioningServiceSoapBinding1" />
     <endpoint address=""
      behaviorConfiguration="GoogleBehavior" binding="basicHttpBinding"
      bindingConfiguration="GoogleServiceSoapBinding" contract="ServiceReferences.Google.Reporting.ReportingService"
      name="GoogleReportingServicePort" />

        <behavior name="GoogleBehavior">
            <clientCertificate x509FindType="FindByThumbprint" storeLocation="CurrentUser" storeName="Root"

when i run my system, it gives me the following error:

System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority ''. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

In order to find where the problem is, first enable System.Net tracing. Add the following markup to the .config file

    <trace autoflush="true" />

        <source name="System.Net"> 
                <add name="System.Net"/>
            <source name="System.Net.Sockets">
                <add name="System.Net"/>
            <source name="System.Net.Cache">
                <add name="System.Net"/>
        <add name="System.Net" value="Verbose" />
        <add name="System.Net.Sockets" value="Verbose" />               
        <add name="System.Net.Cache" value="Verbose" />

Now, run the program and open open the "System.Net.trace.log" file in your /bin/ folder

If you could see the following error message in the log, it means your program can't access the certificate keys

AcquireCredentialsHandle() failed with error 0X8009030D.

if it is IIS, follow this =>

If its a normal program , use this tool to find your private key in the system.

once u found it, usually in the "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" folder,
> goto properties of your key, 
> open security 
> give your user account read + read & execute permissions
> ok

Now run the program and see if it works.

Popular posts from this blog

Print a sales receipt using a thermal printer with C# for POS Application

Automatic redirect upon session timeout using ASP.NET MVC and Javascript