node-ssl-certificates is a node.js library for common ssl-certificates tasks such as fetch, parse and validation.
npm install --save node-ssl-certificates
'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',
// ....
// }
});
fetch the ssl-certificate from a host, url or local file
const { get } = require('node-ssl-certificates');
await get(from, options);
| 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 |
tests the validity of a ssl-certificate, the aspects tested are
const { validate } = require('node-ssl-certificates');
await validate(from, options);
| 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 |
validates a ssl-certificate being signed by some other certificate
const { signedBy } = require('node-ssl-certificates');
await signedBy(from, signer, options);
| option| description | type | default | | --- | ---- | ---- | ---- | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | verbose | print verbose | boolean | false |
print the asn1 tree structure
const { print } = require('node-ssl-certificates');
await printCertificate(from, options);
| option| description | type | default | | --- | ---- | ---- | ---- | | useCryptoModule | use node's crypto module or custom parser | boolean | true | | verbose | print verbose | boolean | false |
thanks
The module is available as open source under the terms of the MIT License.