Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Creates RSA Public Key DER Buffer of TLSSocket.getPeerCertificate Result

License

Notifications You must be signed in to change notification settings

nicolindemann/peer-certificate-to-rsa-pubkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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