Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extract_public_key.erl
-include_lib("public_key/include/public_key.hrl").
extract_public_key(CertPath)
{ok, CertBinary} = file:read_file(CertPath),
CertPemEntries = public_key:pem_decode(CertBinary),
{'Certificate', Cert, _} = lists:keyfind('Certificate', 1, CertPemEntries),
#'OTPCertificate'{
tbsCertificate = #'OTPTBSCertificate'{
subjectPublicKeyInfo = #'OTPSubjectPublicKeyInfo'{
subjectPublicKey = PublicKey
}
}
} = public_key:pkix_decode_cert(Cert, otp)
PublicKey.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.