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.
npm i @imdevesh/verify-valid-sslor
yarn add @imdevesh/verify-valid-sslAll of these functions will throw an error if something is invalid, except the isValid functions, which will return true or false.
const{ validateSSL }=require("@imdevesh/verify-valid-ssl");awaitvalidateSSL(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. |
This function validates that the certificate is an SSL certificate and checks the validity period.
const{ validateSSLCert }=require("@imdevesh/verify-valid-ssl");awaitvalidateSSLCert(cert,options);| Option | Type | Default | Description |
|---|---|---|---|
| skipDateValidation | Boolean | false | Skip verifying the given certificate's validity period. |
This function validates that the certificate is an SSL certificate and checks the validity period.
const{ validateSSLKey }=require("@imdevesh/verify-valid-ssl");awaitvalidateSSLKey(key);This function validates that the certificate and the bundle are certificates, and ensures that the bundle and certificate go together.
const{ validateCertBundle }=require("@imdevesh/verify-valid-ssl";awaitvalidateCertBundle(cert,bundle,options);| Option | Type | Default | Description |
|---|---|---|---|
| skipDateValidation | Boolean | false | Skip verifying the certificate's and bundle's validity period. |
This function validates that the given certificate and key are a matching pair.
const{ validateCertKeyPair }=require("@imdevesh/verify-valid-ssl");awaitvalidateCertKeyPair(cert,key,options);| Option | Type | Default | Description |
|---|---|---|---|
| skipDateValidation | Boolean | false | Skip verifying the given certificate's validity period. |
This function validates the given certificate and that it matches the given domain.
const{ validateCertToDomain }=require("@imdevesh/verify-valid-ssl");awaitvalidateCertToDomain(cert,domain,options);| Option | Type | Default | Description |
|---|---|---|---|
| skipDateValidation | Boolean | false | Skip verifying the given certificate's validity period. |
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("@imdevesh/verify-valid-ssl");if(!(awaitisValidSSL(cert))){return{message: "Sorry, the certificate supplied is not valid."};}The module is available as open source under the terms of the Apache v2.0.