E
Eric Simmons
Hello,
I am trying to run a .NET 2.0 application that I developed and I am
getting the following error:
Key not valid for use in specified state
I am attempting to retrieve the X509Certificate2.PrivateKey as an XML
string via the ToXmlString() function and this error occurs. Below is
an example of the command line call that I used to make my test
certificate.
Using makecert in the following manner:
"C:\Program Files\Microsoft Visual Studio
8\Common7\Tools\Bin\makecert.exe" -r -pe -n "CN=TestCertificate" -b
01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine
-sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
TestCertificate.cer
I have no problem making the call of the ToXmlString() function on my
development machine, which is where I constructed the certificate, but
when I export the certificate from my development machine and import
onto a test machine, I get the "Key not valid for use in specified
state" error message on the test machine. I made sure to export my
private key, and I am even using the Microsoft WSE 3.0 Certificate Tool
to verify that the private key has been properly exported to the test
machine. I even made sure that the user attempting to access the
private key has the proper access permissions.
Below is the stack trace that I am getting when calling the ToXmlString
function
STACK TRACE:
at
System.Security.Cryptography.CryptographicException.ThrowCryptographicEx
ception(Int32 hr)
at System.Security.Cryptography..utils._ExportKey(SafeKeyHandle hKey,
Int32 blobType, Object cspObject)
at
System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(B
oolean includePrivateParameters)
at System.Security.Cryptography.RSA.ToXmlString(Boolean
includePrivateParameters)
Any help on this would be greatly appreciated. Thanks in advance.
I am trying to run a .NET 2.0 application that I developed and I am
getting the following error:
Key not valid for use in specified state
I am attempting to retrieve the X509Certificate2.PrivateKey as an XML
string via the ToXmlString() function and this error occurs. Below is
an example of the command line call that I used to make my test
certificate.
Using makecert in the following manner:
"C:\Program Files\Microsoft Visual Studio
8\Common7\Tools\Bin\makecert.exe" -r -pe -n "CN=TestCertificate" -b
01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine
-sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
TestCertificate.cer
I have no problem making the call of the ToXmlString() function on my
development machine, which is where I constructed the certificate, but
when I export the certificate from my development machine and import
onto a test machine, I get the "Key not valid for use in specified
state" error message on the test machine. I made sure to export my
private key, and I am even using the Microsoft WSE 3.0 Certificate Tool
to verify that the private key has been properly exported to the test
machine. I even made sure that the user attempting to access the
private key has the proper access permissions.
Below is the stack trace that I am getting when calling the ToXmlString
function
STACK TRACE:
at
System.Security.Cryptography.CryptographicException.ThrowCryptographicEx
ception(Int32 hr)
at System.Security.Cryptography..utils._ExportKey(SafeKeyHandle hKey,
Int32 blobType, Object cspObject)
at
System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(B
oolean includePrivateParameters)
at System.Security.Cryptography.RSA.ToXmlString(Boolean
includePrivateParameters)
Any help on this would be greatly appreciated. Thanks in advance.