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

Martin Karlsson <>
Mon Feb 9 00:31:20 CET 2015


Hi Eric,

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

You should look into public_key:der_decode/2

To get a SubjectPublicKeyInfo to rsa_public_key() you need to do something
like this:

{0, Res} = Info#'SubjectPublicKeyInfo'.subjectPublicKey,
public_key:der_decode('RSAPublicKey', Res).

We do something similar but do not work with certificates.

Hope this helps,

Cheers,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150209/a486225b/attachment.html>


More information about the erlang-questions mailing list