[erlang-questions] Retrieve public key from DER encoded certificate

Eric Meadows-Jönsson eric.meadows.jonsson@REDACTED
Sat Jan 31 14:52:52 CET 2015


I have a DER encoded certificate that i decode to #'Certificate' with
public_key:pkix_decode_cert(Cert, plain). From the certificate I
retrieve #'SubjectPublicKeyInfo' which I pass to
publick_key:pem_entry_decode/1 to get rsa_public_key() or dsa_public_key().

But this function call fails because pem_entry_decode/1 does not seem to
expect #'SubjectPublicKeyInfo' to be already decoded. It already has the
structure that it tries to decode to here
https://github.com/erlang/otp/blob/382943f9a943eb4215a297f9445e21fb9b5c0633/lib/public_key/src/public_key.erl#L119-L120
.

How should I retrieve rsa_public_key() | dsa_public_key() from a DER
encoded certificate?

-- 
Eric Meadows-Jönsson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150131/f61fe4af/attachment.htm>


More information about the erlang-questions mailing list