X509Certificate2.HasPrivateKey = true, but no PrivateKey?

  • Thread starter Thread starter Dominik Amon
  • Start date Start date
D

Dominik Amon

Hi,

I have a X509 certifikate, with public- and privatekey.
For test reasons, I programed a small Consoleapplication, which executes
with my user rights (Administrator).

When I am reading an X509Certificate, the property HasPrivateKey of the
X509Certificate2 is set to "true". I can also check the publickey

But if I want to use the PrivateKey Property, after a while i get the error
message "Keyset does not exist",

That's the stacktrace for it:
bei System.Security.Cryptography.Utils.CreateProvHandle(CspParameters
parameters, Boolean randomKeyContainer)\r\n bei
System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType
keyType, CspParameters parameters, Boolean randomKeyContainer, Int32
dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\r\n
bei System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()\r\n
bei System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32
dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)\r\n bei
System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters
parameters)\r\n bei
System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()\r\n
bei SecurityHelper.SignatureHelper.FindCertificate(CertificateIdentification
certIdentification, String certAttributeData) in D:\\DATEN\\AmonD\\Visual
Studio
2005\\Projects\\ConsoleApplication1\\ConsoleApplication1\\SignatureHelper.cs:Zeile
120.

I don't have a plan, what's the reason? :-(

Thanks,
Dominik
 
Back
Top