Unable to cast object of type 'Org.BouncyCastle.Asn1.DerSequence' to type 'Org.BouncyCastle.Asn1.DerInteger'

前端 未结 1 1963
我在风中等你
我在风中等你 2021-01-14 08:45

in my c # project, I put this piece of code :

initially, I recovered from the certificate that I created with bouncy castle, the key pair, then I extract the private

相关标签:
1条回答
  • 2021-01-14 09:31

    Since you are writing the private key out in PKCS#8 format, the appropriate PEM header is "BEGIN PRIVATE KEY" (i.e. without the "RSA"). The PEM data already contains the algorithm for the key, and "BEGIN RSA PRIVATE KEY" has the meaning of a directly encoded RsaPrivateCrtKeyParameters, which is not what you are writing out.

    I was able to parse your example file after changing the headers to "BEGIN PRIVATE KEY". ReadObject call then returns an RsaPrivateCrtKeyParameters object.

    0 讨论(0)
提交回复
热议问题