c# - Cannot read private key on X509Certificate2 -


win 8.1 64-bit. .net 4.5. powershell 4.0. (though think problem related .net in general , not specific powershell.)

i generate self-signed certificate this:

new-selfsignedcertificate -dnsname 'theincrediblehulk' -certstorelocation cert:\currentuser\my 

then retrieve cert:

$cert = get-item cert:\currentuser\my\9e5a8322b890da1247bd98bdab288ca9d11cf99e 

the certificate has private key:

$cert.hasprivatekey true 

or it?

$cert.privatekey (null) 

why privatekey member null? how can retrieve private key?

for else happens across this, suspect issue related storage provider used new-selfsignedcertificate (see http://blogs.technet.com/b/vishalagarwal/archive/2010/03/30/verifying-the-private-key-property-for-a-certificate-in-the-store.aspx, talks problem microsoft software key storage provider , .net classes). there's powershell script available on technet creates self-signed certificates, , defaults using different storage provider.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -