0.3.0 • Published 4 years ago

openssl-verify v0.3.0

Weekly downloads
30
License
MIT
Repository
github
Last release
4 years ago

OpenSSL Certificate validation utility

A wrapper around OpenSSL commands to allow certificate validation for Node.js

Usage

Install with npm: npm install openssl-verify --save

var openssl = require('openssl-verify');
var fs = require('fs');

var certificate = fs.readFileSync('certificate.pem', "utf8");

openssl.verifyCertificate(certificate, 'resources/cafolder', function(result) {
        console.log(result);
})

API

verifyCertificate(cert, caDir, caFile, cb)

Checks the validity of a provided certificate, and wheter or not it is trusted by any CA present in caDir.

  • cert: String contents of the certificate (PEM encoded)
  • caDir: String folder with trusted CA's
  • caFile: String file of trusted CA's
  • cb: Function in the form of function(err, result) where result is an object containing boolean flags validCert, verifiedCA and expired; as well as output containing the raw output from OpenSSL. Those flags are evaluated in order, so if one of them is false the rest won't be included (they would be meaningless)