npm package 'node-ssl-certificates'

Popularity: Medium (more popular than 90% of all packages)
Description: a node.js library for fetching, parsing and validating ssl-certificates
Installation: npm install node-ssl-certificates
Last version: 0.11.0 (Download)
Homepage: https://github.com/jmarroyave-compsci/node-ssl-certificates#readme
Size: 284.25 kB
License: MIT
Keywords: ssl, certificates, chains, altnames, x509

Activity

Last modified: August 11, 2022 9:27 PM (10 months ago)
Versions released in one year: 13
Weekly downloads: 30
07/24/2022095190285380036912released versions / week
  • Versions released
  • Weekly downloads

Readme

<h1 align="center"> node-ssl-certificates </h1> <p align="center"> <b >a node.js library for fetching, parsing and validating ssl-certificates</b> </p><hr/>

Description

node-ssl-certificates is a node.js library for common ssl-certificates tasks such as fetch, parse and validation.

Features

  • zero third-party dependencies
  • async/await support
  • optional use of node's crypto module
  • asn1 viewer

Installation

npm install --save node-ssl-certificates

Usage

node.js:

'use strict';
 
const sslCertificates = require('node-ssl-certificates')
 
sslCertificates.get('nodejs.org').then(function (certificate) {
  console.log(certificate.issuer)
  // { 
  //   C: 'GB',
  //   ST: 'Greater Manchester',
  //   L: 'Salford',
  //   ....
  // }
});

API Documentation

get

fetch the ssl-certificate from a host, url or local file

const { get } = require('node-ssl-certificates');

await get(from, options);

args

  • from: string [ p.e.: https://url/cert.der, nodejs.com, /tmp/cert.pem ]
  • options: object

| option| description | type | default | | --- | ---- | ---- | ---- | | includeChain | includes chain's certificates | boolean | false | | includeCertificates | includes the raw certificates string in the response object | boolean | false | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | port | port to connect to | int | 443 | | verbose | print verbose | boolean | false |

validate

tests the validity of a ssl-certificate, the aspects tested are

  • Is date valid?
  • Is the domain valid?
  • Is the chain of trust valid?
  • Is the root CA self signed?
  • Was the certificate revoked by it's issuer
  • Are the cryptographic details valid
  • Is the root CA valid?
const { validate } = require('node-ssl-certificates');

await validate(from, options);

args

  • from: string [ p.e.: https://url/cert.der, nodejs.com, /tmp/cert.pem ]
  • options: object

| option| description | type | default | | --- | ---- | ---- | ---- | | domain | domain name to validate | string | null | | includeChain | includes chain's certificates | boolean | false | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | port | port to connect to | int | 443 | | verbose | print verbose | boolean | false |

signedBy

validates a ssl-certificate being signed by some other certificate

const { signedBy } = require('node-ssl-certificates');

await signedBy(from, signer, options);

args

  • from: string [ p.e.: https://url/cert.der, nodejs.com, /tmp/cert.pem ]
  • signer: string [ p.e.: https://url/cert.der, nodejs.com, /tmp/cert.pem ]
  • options: object

| option| description | type | default | | --- | ---- | ---- | ---- | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | verbose | print verbose | boolean | false |

print

print the asn1 tree structure

const { print } = require('node-ssl-certificates');

await printCertificate(from, options);

args

  • from: string [ p.e.: https://url/cert.der, nodejs.com, /tmp/cert.pem ]
  • options: object

| option| description | type | default | | --- | ---- | ---- | ---- | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | verbose | print verbose | boolean | false |

return

  • string: with the asn tree structure

Reference packages

thanks

License

The module is available as open source under the terms of the MIT License.