1
0
Fork 0
forked from svrjs/svrjs
This repository has been archived on 2024-11-10. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs/node_modules/ocsp/lib/ocsp/check.js
2023-07-29 20:33:28 +02:00

46 lines
843 B
JavaScript

'use strict';
var ocsp = require('../ocsp');
var rfc2560 = require('asn1.js-rfc2560');
module.exports = function check(options, cb) {
var sync = true;
var req;
function done(err, data) {
if (sync) {
sync = false;
process.nextTick(function() {
cb(err, data);
});
return;
}
cb(err, data);
}
try {
req = ocsp.request.generate(options.cert, options.issuer);
} catch (e) {
return done(e);
}
var ocspMethod = rfc2560['id-pkix-ocsp'].join('.');
ocsp.utils.getAuthorityInfo(req.cert, ocspMethod, function(err, uri) {
if (err)
return done(err);
ocsp.utils.getResponse(uri, req.data, function(err, raw) {
if (err)
return done(err);
ocsp.verify({
request: req,
response: raw
}, done);
});
});
sync = false;
};