How to get private key from PKCS#12 (.p12) file using C#

后端 未结 4 1397
忘了有多久
忘了有多久 2021-01-13 16:30

Im trying to sign some data using PKCS#12 certificate ,however i have problem with obtaining private key from PKCS#12 (.p12) file.

    public byte[] sign(str         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 17:13

    I had a similar problem which I posted here, although it is not the same thing for you, the problem may be also permissions.
    My suggestions are, first, you have to make sure (which I suppose you already did) that the private key is exportable and you have permissions to the file.
    Next, try exporting the content type as X509ContentType.Pkcs12 instead of X509ContentType.Pfx
    Finally, if it is possible, why don't you try importing it to the certstore. I believe that's more secure. The steps are in the link above.

提交回复
热议问题