Comparing version 0.2.6 to 0.3.0
36
index.js
@@ -1,3 +0,3 @@ | ||
var x509 = require('./build/Release/x509'); | ||
var fs = require('fs'); | ||
@@ -9,2 +9,34 @@ exports.version = x509.version; | ||
exports.verify = function(certPath, CABundlePath, cb) { | ||
if (!certPath) { | ||
throw new TypeError('Certificate path is required'); | ||
} | ||
if (!CABundlePath) { | ||
throw new TypeError('CA Bundle path is required'); | ||
} | ||
fs.stat(certPath, function(certPathErr) { | ||
if (certPathErr) { | ||
return cb(certPathErr); | ||
} | ||
fs.stat(CABundlePath, function(bundlePathErr) { | ||
if (bundlePathErr) { | ||
return cb(bundlePathErr); | ||
} | ||
try { | ||
x509.verify(certPath, CABundlePath); | ||
cb(null); | ||
} | ||
catch (verificationError) { | ||
cb(verificationError); | ||
} | ||
}); | ||
}); | ||
}; | ||
exports.parseCert = function(path) { | ||
@@ -21,2 +53,2 @@ var ret = x509.parseCert(path); | ||
return ret; | ||
}; | ||
}; |
{ | ||
"name": "x509", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"description": "Simple X509 certificate parser.", | ||
@@ -5,0 +5,0 @@ "author": "Colton Baker", |
@@ -88,3 +88,3 @@ node-x509 | ||
/* | ||
cert = { subject: | ||
cert = { subject: | ||
{ countryName: 'US', | ||
@@ -98,3 +98,3 @@ postalCode: '10010', | ||
commonName: '*.nodejitsu.com' }, | ||
issuer: | ||
issuer: | ||
{ countryName: 'GB', | ||
@@ -117,2 +117,27 @@ stateOrProvinceName: 'Greater Manchester', | ||
#### x509.verify(`cert`, `CABundlePath`, function(err, result){ /*...*/}) | ||
Performs basic certificate validation against a bundle of ca certificates. | ||
It accepts an error-first callback as first argument. If the error is null, then | ||
the certificate is valid. | ||
The error messages are the same returned by openssl: [x509_verify_cert_error_string](https://www.openssl.org/docs/manmaster/crypto/X509_STORE_CTX_get_error.html) | ||
**Note:** | ||
As now, this function only accepts absolute paths to existing files as arguments | ||
```js | ||
const x509 = require('x509'); | ||
x509.verify( | ||
__dirname + '/certs/user.com.crt', | ||
__dirname + 'enduser-example.com.chain', | ||
function(err, result){ /*...*/} | ||
); | ||
``` | ||
## Examples | ||
@@ -119,0 +144,0 @@ Checking the date to make sure the certificate is active: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22842
43
161
1