# ssl-key-csr-validator

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

Latest version **1.1.0** (published 2022-06-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install ssl-key-csr-validator
pnpm add ssl-key-csr-validator
yarn add ssl-key-csr-validator
bun add ssl-key-csr-validator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-06-18 |
| First published | 2022-03-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 22.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Savan Padaliya |
| Maintainers | savanpadaliya |
| Keywords | ssl, openssl, certificate, ssl, rsa, keys, matcher, utility |

## Links

- npm: https://www.npmjs.com/package/ssl-key-csr-validator
- Repository: https://github.com/PadaliyaSavan88/ssl-key-csr-validator
- Homepage: https://github.com/PadaliyaSavan88/ssl-key-csr-validator#readme
- Issues: https://github.com/PadaliyaSavan88/ssl-key-csr-validator/issues
- npm.io page: https://npm.io/package/ssl-key-csr-validator

## Dependencies (2)

- [async](https://npm.io/package/async.md) *
- [which](https://npm.io/package/which.md) *

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-06-18
- 1.0.2 — 2022-03-28
- 1.0.1 — 2022-03-20
- 1.0.0 — 2022-03-20

## README

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

This tiny utility uses [Open SSL](https://openssl.org) 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.

```js
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.

```js
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) {
  // ...
});
```

---
_Source: https://npm.io/package/ssl-key-csr-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
