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

可紊 提交于 2019-12-06 13:58:56

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!