PJ2010
10-15-2010, 06:25 PM
OK I finally learned the ins and outs of SSL certificates (very complicated but several hours of studying and I think I get it) including exporting and importing to your PC, and I cooked up a simple Hello World app following the tutorial here: (Google this): "How To Use basicHttpBinding with Certificate Authentication from Windows"
I had already bought a SSL Certificate from DASP called RapidSSL. However--and this is the DASP question--I'm not sure this certificate supports encryption--it appears to lack a private key. Does it have a private key? I don't think so--and why not??? I cannot run my program without a private key (I think this is the error I'm getting, see below the output).
When I go to https://www.MYCOMPANYNAME.com (the DASP account that has this RapidSSL in it), I can, when I right-click the 'padlock' icon, see everything but the private key. I see version, public key, thumbprint, etc. And I can store this certificate (import it) to the '/My' folder in Windows where such certificates are kept for users, but, no private key??? Any idea why? Do I have t pay extra for a private key version?
Below are my web.config files for the WCF project and the error message.
PJ
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="WcfServiceLibrary1Secure1.Service1Behavior"
name="WcfServiceLibrary1Secure1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1"
contract="WcfServiceLibrary1Secure1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://MYCOMPANYNAMEprogramming.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="Binding1">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceLibrary1Secure1.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
<serviceCredentials>
<serviceCertificate findValue="MYCOMPANYNAMEprogramming.com" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
////////////
Server Error in '/Secure10162010Website' Application.
--------------------------------------------------------------------------------
Keyset does not exist
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicExceptio n: Keyset does not exist
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[CryptographicException: Keyset does not exist
]
System.Security.Cryptography.Utils.CreateProvHandl e(CspParameters parameters, Boolean randomKeyContainer) +7714910
System.Security.Cryptography.Utils.GetKeyPairHelpe r(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +67
System.Security.Cryptography.RSACryptoServiceProvi der.GetKeyPair() +83
System.Security.Cryptography.RSACryptoServiceProvi der..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +226
System.Security.Cryptography.RSACryptoServiceProvi der..ctor(CspParameters parameters) +9
System.Security.Cryptography.X509Certificates.X509 Certificate2.get_PrivateKey() +202
System.ServiceModel.Security.SecurityUtils.EnsureC ertificateCanDoKeyExchange(X509Certificate2 certificate) +69
[ArgumentException: The certificate 'CN=MYCOMPANYNAMEprogramming.com, OU=Domain Control Validated - RapidSSL(R), OU=See www.rapidssl.com/resources/cps (c)10, OU=GT55691249, O=MYCOMPANYNAMEprogramming.com, C=US, SERIALNUMBER=lFZWoksXE/ZiQtB9cvQxXx1nCG7wwQvH' must have a private key that is capable of key exchange. The process must have access rights for the private key.]
//
[ServiceActivationException: The service '/Secure10162010Website/WcfServiceLibrary1Secure1.svc' cannot be activated due to an exception during compilation. The exception message is: The certificate 'CN=MYCOMPANYNAMEprogramming.com, OU=Domain Control Validated - RapidSSL(R), OU=See www.rapidssl.com/resources/cps (c)10, OU=GT55691249, O=MYCOMPANYNAMEprogramming.com, C=US, SERIALNUMBER=lFZWoksXE/ZiQtB9cvQxXx1nCG7wwQvH' must have a private key that is capable of key exchange. The process must have access rights for the private key..]
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4209
I had already bought a SSL Certificate from DASP called RapidSSL. However--and this is the DASP question--I'm not sure this certificate supports encryption--it appears to lack a private key. Does it have a private key? I don't think so--and why not??? I cannot run my program without a private key (I think this is the error I'm getting, see below the output).
When I go to https://www.MYCOMPANYNAME.com (the DASP account that has this RapidSSL in it), I can, when I right-click the 'padlock' icon, see everything but the private key. I see version, public key, thumbprint, etc. And I can store this certificate (import it) to the '/My' folder in Windows where such certificates are kept for users, but, no private key??? Any idea why? Do I have t pay extra for a private key version?
Below are my web.config files for the WCF project and the error message.
PJ
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="WcfServiceLibrary1Secure1.Service1Behavior"
name="WcfServiceLibrary1Secure1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1"
contract="WcfServiceLibrary1Secure1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://MYCOMPANYNAMEprogramming.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="Binding1">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceLibrary1Secure1.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
<serviceCredentials>
<serviceCertificate findValue="MYCOMPANYNAMEprogramming.com" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
////////////
Server Error in '/Secure10162010Website' Application.
--------------------------------------------------------------------------------
Keyset does not exist
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicExceptio n: Keyset does not exist
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[CryptographicException: Keyset does not exist
]
System.Security.Cryptography.Utils.CreateProvHandl e(CspParameters parameters, Boolean randomKeyContainer) +7714910
System.Security.Cryptography.Utils.GetKeyPairHelpe r(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +67
System.Security.Cryptography.RSACryptoServiceProvi der.GetKeyPair() +83
System.Security.Cryptography.RSACryptoServiceProvi der..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +226
System.Security.Cryptography.RSACryptoServiceProvi der..ctor(CspParameters parameters) +9
System.Security.Cryptography.X509Certificates.X509 Certificate2.get_PrivateKey() +202
System.ServiceModel.Security.SecurityUtils.EnsureC ertificateCanDoKeyExchange(X509Certificate2 certificate) +69
[ArgumentException: The certificate 'CN=MYCOMPANYNAMEprogramming.com, OU=Domain Control Validated - RapidSSL(R), OU=See www.rapidssl.com/resources/cps (c)10, OU=GT55691249, O=MYCOMPANYNAMEprogramming.com, C=US, SERIALNUMBER=lFZWoksXE/ZiQtB9cvQxXx1nCG7wwQvH' must have a private key that is capable of key exchange. The process must have access rights for the private key.]
//
[ServiceActivationException: The service '/Secure10162010Website/WcfServiceLibrary1Secure1.svc' cannot be activated due to an exception during compilation. The exception message is: The certificate 'CN=MYCOMPANYNAMEprogramming.com, OU=Domain Control Validated - RapidSSL(R), OU=See www.rapidssl.com/resources/cps (c)10, OU=GT55691249, O=MYCOMPANYNAMEprogramming.com, C=US, SERIALNUMBER=lFZWoksXE/ZiQtB9cvQxXx1nCG7wwQvH' must have a private key that is capable of key exchange. The process must have access rights for the private key..]
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4209