New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ssl-key-csr-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssl-key-csr-validator

Check that if private key and csr key matches to SSL certificate or not.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Check that SSL (X509) certificate matches it's private key and csr key

This tiny utility uses Open SSL to verify that:

  • input string or file is a valid PEM-encoded X509 certificate
  • input string or file is a valid PEM-encoded RSA private key
  • input string or file is a valid PEM-encoded REQ CSR key
  • PEM-encoded X509 certificate matches PEM-encoded private RSA key
  • PEM-encoded X509 certificate matches PEM-encoded CSR RQ key
  • RSA private key is not encrypted with DES3 (does not require passphrase)

Usage

To match certificate and private key, use below code example.

var ssl = require('ssl-key-csr-validator');

var certPem = fs.readFileSync('my-certificate.pem');
var keyPem = fs.readFileSync('my-key.pem');

ssl.match(certPem, keyPem, function(err, matches) {
  if (err)
    return console.error('Something\'s wrong: cert invalid, key invalid, key encrypted or else');
  if (matches)
    console.log('Yay, it matches.');
  else
    console.log('You\'ve picked the wrong key, bro.');
});

// or read directly from files (feeding them to openssl):

ssl.matchFiles('my-certificate.pem', 'my-key.pem', function(err, matches) {
  // ...
});

To match certificate and csr key, use below code example.

var ssl = require('ssl-key-csr-validator');

var certPem = fs.readFileSync('my-certificate.pem');
var keyPem = fs.readFileSync('my-key.pem');

ssl.matchCsr(certPem, csrPem, function(err, matches) {
  if (err)
    return console.error('Something\'s wrong: cert invalid, csr invalid, key encrypted or else');
  if (matches)
    console.log('Yay, it matches.');
  else
    console.log('You\'ve picked the wrong key, bro.');
});

// or read directly from files (feeding them to openssl):

ssl.matchCsrFiles('my-certificate.pem', 'my-csr.pem', function(err, matches) {
  // ...
});

Keywords

FAQs

Package last updated on 18 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc