Extract public key from certificate x509

馋奶兔 提交于 2019-12-11 06:02:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!