パッケージの詳細

ssl-validator

Losant33.6kMIT4.1.0

Validator for certificates, bundles, and keys

ssl, openssl, certificates, keys

readme

Node SSL Validator

This module is a validator for SSL Certificates using the PEM node module. You can validate SSL Keys, SSL Certificates, SSL Certificate Domains, SSL Certificate Bundles, etc.

Build Status npm version

Installation

npm install ssl-validator

or

yarn add ssl-validator

API Documentation

All of these functions will throw an error if something is invalid, except the isValid functions, which will return true or false.

Validate SSL

const { validateSSL } = require('ssl-validator');

await validateSSL(cert, options);
Option Type Default Description
skipDateValidation Boolean false Skip verifying the certificate's and/or bundle's validity period.
key String When given, validates that the key and certificate are a pair.
domain String When given, verifies the certificate is valid for this domain. e.g. 'github.com'
bundle String When given, verifies the certificate bundle and certificate go together.
skipFormatValidation Boolean false When true skip validation the format of the certificate and the key.
password String A password that will be given to openssl when verfiying the key.

Validate SSL Cert

This function validates that the certificate is an SSL certificate and checks the validity period.

const { validateSSLCert } = require('ssl-validator');

await validateSSLCert(cert, options);
Option Type Default Description
skipDateValidation Boolean false Skip verifying the given certificate's validity period.
skipFormatValidation Boolean false When true, skip validation the format of the certificate.

Validate SSL Key

This function validates that the certificate is an SSL certificate and checks the validity period.

const { validateSSLKey } = require('ssl-validator');

await validateSSLKey(key, options);
Option Type Default Description
password String A password that will be given to openssl when verfiying the key.
skipFormatValidation Boolean false When true, skip validation the format of the key.

Validate Cert Bundle

This function validates that the certificate and the bundle are certificates, and ensures that the bundle and certificate go together.

const { validateCertBundle } = require('ssl-validator');

await validateCertBundle(cert, bundle, options);
Option Type Default Description
skipDateValidation Boolean false Skip verifying the certificate's and/or bundle's validity period.
key String When given, validates that the key and certificate are a pair.
domain String When given, verifies the certificate is valid for this domain. e.g. 'github.com'
skipFormatValidation Boolean false When true skip validation the format of the certificate and the key.
password String A password that will be given to openssl when verfiying the key.

Validate Cert Key Pair

This function validates that the given certificate and key are a matching pair.

const { validateCertKeyPair } = require('ssl-validator');

await validateCertKeyPair(cert, key, options);
Option Type Default Description
skipDateValidation Boolean false Skip verifying the certificate's and/or bundle's validity period.
domain String When given, verifies the certificate is valid for this domain. e.g. 'github.com'
bundle String When given, verifies the certificate bundle and certificate go together.
skipFormatValidation Boolean false When true skip validation the format of the certificate and the key.
password String A password that will be given to openssl when verfiying the key.

Validate Cert To Domain

This function validates the given certificate and that it matches the given domain.

const { validateCertToDomain } = require('ssl-validator');

await validateCertToDomain(cert, domain, options);
Option Type Default Description
skipDateValidation Boolean false Skip verifying the certificate's and/or bundle's validity period.
key String When given, validates that the key and certificate are a pair.
bundle String When given, verifies the certificate bundle and certificate go together.
skipFormatValidation Boolean false When true skip validation the format of the certificate and the key.
password String A password that will be given to openssl when verfiying the key.

IsValid Functions

Each of the functions listed above (validateSSL, validateSSLCert, etc.) has a counterpart that will not throw any errors but will return true when valid and false when not valid. All arguments and options are listed above are valid.

Original Function Name Predicate Function Name
validateSSL isValidSSL
validateSSLCert isValidSSLCert
validateSSLKey isValidSSLKey
validateCertBundle isValidCertBundle
validateCertKeyPair isValidCertKeyPair
validateCertToDomain isValidCertToDomain
const { isValidSSL } = require('ssl-validator');

if (!(await isValidSSL(cert))) {
  return { message: 'Sorry, the certificate supplied is not valid.' };
}

License

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

更新履歴

SSL Validator Changelog

4.1.0 - 2024-08-29

  • Upgraded various dependencies & dev dependencies
  • Replaced main index file with exact module.exports functions instead of building the module.export object.
  • Replaced travis with github actions.

4.0.0 - 2024-02-15

  • Upgraded various dependencies & dev dependencies
  • Only supports node version 18 or higher.
  • New option skipFormatValdiation to be set on validateSSLKey, validateSSL, validateSSLCert to skip header and footer key and certification validation.
  • Add remove Node 16 from travis.yml.

3.0.0 - 2023-08-31

  • Upgraded various dependencies & dev dependencies
  • Only supports node version 16 or higher.
  • Support for ECDSA certificates has been added.
  • validateSSLKey now returns the public key instead of the modulus.
  • validateSSL no longer returns the modulus on the field keyMod.
  • validateSSL now returns the public key on the field publicKey.
  • Add Node 20 and remove Node 14 from travis.yml.

2.0.1 - 2023-04-20

  • Upgraded various dependencies & dev dependencies
  • New option password to be set on validateSSLKey and validateSSL

2.0.0 - 2023-04-20

  • Only supports node version 14 or higher.
  • Upgrade dependencies including pem to v1.14.7 and ramda to v0.29.0.

1.0.7 - 2020-10-22

  • Update development/test dependencies.
  • Update ramda dependency to 0.27.1.
  • Add Node 14 and 15 to travis.yml.
  • Fix a few minor linting issues.

1.0.6 - 2020-02-25

  • update ramda dependency to 0.27.0
  • added missing async keyword to the function validateSSLKey
  • fixed domainRegTest and added tests around validation of domains to wildcard certs
  • Update development/test dependencies
  • Update pem dependency
  • Add Node 11, 12, and 13 to travis.yml
  • Remove Node 8 and 9 from travis.yml (since mocha/eslint no longer support them). Note that ssl-validator itself still works on node 8/9.

1.0.5 - 2019-06-28

  • Update pem dependency
  • Fix a spelling errors, improved error messages
  • Add Node 12 to travis.yml

1.0.4 - 2019-01-07

  • Update pem dependency
  • Fix issue with bundle/cert check order

1.0.3 - 2019-01-07

  • Update development/test dependencies
  • Update pem dependency
  • Update ramda dependency
  • Update license year
  • Add Node 11 to travis.yml

1.0.2 - 2018-10-22

  • Update development/test dependencies
  • Update pem dependency
  • Fix a few typos / linter errors
  • Add Node 10 to travis.yml

1.0.1 - 2018-05-08

  • Handle wildcard domains correctly for matching certificates to domains

1.0.0 - 2018-04-04

  • Initial release