Cert Utils
Cert utils implements the CertService, Certinfo and CertvalidationError classes for the timestamps.
Install
$ yarn add @techteamer/cert-utils
Usage
const { CertService } = require('@techteamer/cert-utils')
...
this.certService = new CertService('latin1')
Params
- encode type(optional): config.get('certService.encoding', 'latin1')
Default config
"certService": {
"encoding": 'latin1'
}
Public methods
parseCert
: get cert info from certBuffer
async parseCert(certBuf, password, certType = CertService.CertType.P12)
parseCertFromFile
: get cert info from file
async parseCertFromFile (certPath, password)
verifyCert
: Verifies that the provided certificate is valid
async verifyCert (pemCert, pemCaCert, verifyOcsp = false)
getPemCertBody
: Parses the provided certificate's body and return it as a buffer
async getPemCertBody (pemCert)
CertInfo
: return cert info
Example:
CertInfo {
subject: {
C: 'HU',
L: 'Budapest',
O: 'Test Kft.',
organizationIdentifier: '00000000-20-00',
CN: 'Teszt',
GN: 'Teszt',
SN: 'Teszt',
emailAddress: 'teszt@localhost',
serialNumber: '1.3.6.1.4.1.00000.2.2.99.00000'
},
issuer: {
C: 'HU',
L: 'Budapest',
O: 'Microsec Ltd.',
OU: 'e-Szigno CA',
CN: 'e-Szigno Test CA3'
},
notBefore: 2019-11-26T11:54:00.000Z,
notAfter: 2020-02-27T11:54:00.000Z,
decrypted: true
}
certinfo.validator
: get cert validation info
Example
{
ok: false,
info: { info: { isEffective: true, isExpired: true } },
message: 'Cert validation error, cert is expired'
}
CertType
: return cert types
{ P12: 'P12', PEM: 'PEM' }