Makecert problem under Windows 7
Posted
by TimK
on Stack Overflow
See other posts from Stack Overflow
or by TimK
Published on 2010-04-01T19:20:13Z
Indexed on
2010/04/01
19:23 UTC
Read the original article
Hit count: 408
I'm creating a certificate to use with an SslStream, and I've been doing it this way under XP:
makecert -r -pe -n "CN=aName" -ss my -sr localmachine -sky exchange
-sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 server.cer
If I understand this correctly, this creates a certificate in server.cer, and creates a private key for it in my personal certificate store. Once I have done this, I can create a certificate object like this:
X509Certificate.CreateFromCertFile(certFile);
I then use it with the SSLStream, and everything works fine.
Now that I have switched to Windows 7, the private key seems to be disappearing every time I restart the machine. I run a command prompt as Administrator, and execute the same makecert command shown above. This succeeds and the SSL connection works correctly. If I restart the machine, the call to AuthenticateAsServer fails with the exception "The server mode SSL must use a certificate with the associated private key."
Why is the private key disappearing? What do I need to do to make it stick around?
© Stack Overflow or respective owner