Skip to content

PKCS#1 to PKCS#8 convertion #592

Answered by peterdettman
dvkovner asked this question in Q&A
Discussion options

You must be logged in to vote

Try this change:

    new AlgorithmIdentifier(PkcsObjectIdentifiers.RsaEncryption, DerNull.Instance)

Probably the whole example could be reduced to:

    var publicKey = DotNetUtilities.FromX509Certificate(certificate).GetPublicKey();
    return SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey).GetEncoded(Asn1Encodable.Der);

which will work for other algorithms besides RSA too.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dvkovner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants