nicolindemann / peer-certificate-to-rsa-pubkey

Creates RSA Public Key DER Buffer of TLSSocket.getPeerCertificate Result

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Creates RSA Public Key DER Buffer of TLSSocket.getPeerCertificate Result

License:MIT License


Languages

Language:JavaScript 100.0%