【发布时间】:2018-02-19 19:23:39
【问题描述】:
我需要从其 SSL 证书中获取服务器的公钥。我得到的证书如下:
https.request(options, res => {
const cert = res.connection.getPeerCertificate();
const publicKey = cert.????()
}
我找不到从证书中获取公钥的方法。有没有图书馆可以做到这一点?
我希望使用公钥来加密一些数据:
const encryptedBuffer = crypto.publicEncrypt({
key: publicKey,
padding: crypto.constants.RSA_PKCS1_PADDING
}, utf8Payload)
我看到证书有一个“原始”缓冲区,但使用它作为 publicKey 失败。
【问题讨论】: