Creates RSA Public Key DER Buffer of TLSSocket.getPeerCertificate Result.
Based on this stackoverflow question and answer.
npm install peer-certificate-to-rsa-pubkey
var rsaPubKey = require('peer-certificate-to-rsa-pubkey')
const exampleRequestHandler = (req, res) => {
const rsaPubKeyBuffer = /* Buffer */ rsaPubKey(res.connection.getPeerCertificate())
// rsaPubKeyBuffer is a DER represantion of the public key
}
If TLSSocket.getPeerCertificate does not return RSA encrypted public key information an error will be thrown.
npm test