1.0.0 • Published 7 years ago

peer-certificate-to-rsa-pubkey v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

peer-certificate-to-rsa-pubkey

Creates RSA Public Key DER Buffer of TLSSocket.getPeerCertificate Result.

Based on this stackoverflow question and answer.

Install

npm install peer-certificate-to-rsa-pubkey

Usage

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.

Testing and Code Coverage

npm test