Extract private key from pfx file or certificate store WITHOUT using OpenSSL on Windows

后端 未结 5 2385
孤街浪徒
孤街浪徒 2021-02-19 08:42

As the title suggests I would like to export my private key without using OpenSSL or any other third party tool. If I need a .cer file or .pfx file I c

5条回答
  •  渐次进展
    2021-02-19 09:31

    Hm. Have you tried opening the cert store, and getting the private key that way? Pretty sure this will only work with RSA/DSA certs though.

    $store = New-Object System.Security.Cryptography.X509Certificates.X509Store([System.Security.Cryptography.X509Certificates.StoreName]::My,"localmachine")
    $store.Open("MaxAllowed")
    $cert = $store.Certificates | ?{$_.subject -match "^CN=asdasd"}
    $cert.PrivateKey.ToXmlString($false)
    $store.Close()
    
    

提交回复
热议问题