Created
June 25, 2015 04:45
-
-
Save mururu/c3e2c067f57976da8afe to your computer and use it in GitHub Desktop.
extract_public_key.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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