问题
I am looking for a way to extract public key from certificate x509 (PEM format) in javascript like this one:
openssl x509 -in cert.cer -pubkey -noout > pub.txt
回答1:
You need something that can parse ASN.1 structure. You could use pkijs.
Demo can be found here
回答2:
var cert = forge.pki.certificateFromPem(pem);
var pem =
forge.pki.publicKeyToPem(cert.publicKey)
Thanks halloulaguesmi. This seems to be working perfectly.
来源:https://stackoverflow.com/questions/44675333/extract-public-key-from-certificate-x509