Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
req.on('end', function() {
var body = Buffer.concat(chunks);
var ocspReq;
try {
ocspReq = rfc2560.OCSPRequest.decode(body, 'der');
} catch (e) {
return done(errRes('malformed_request'));
}
self.getResponses(ocspReq, function(err, responses) {
// Assume not found
if (err) {
res.writeHead(404);
res.end();
return;
}
return done(responses);
});
});
} ],
requestExtensions: [ {
extnID: rfc2560['id-pkix-ocsp-nonce'],
critical: false,
extnValue: rfc2560.Nonce.encode(crypto.randomBytes(16), 'der')
} ]
};
var req = {
tbsRequest: tbs
};
return {
id: sha1(rfc2560.CertID.encode(certID, 'der')),
certID: certID,
data: rfc2560.OCSPRequest.encode(req, 'der'),
// Just to avoid re-parsing DER
cert: cert,
issuer: issuer
};
};
req.once('end', () => {
var body = JSON.parse(chunks);
var ocspReq = rfc2560.OCSPRequest.decode(
new Buffer(body.ocsp, 'base64'),
'der');
ocspServer.getResponses(ocspReq, (err, responses) => {
if (err)
throw err;
res.writeHead(200, { 'Content-Type': 'application/json' });
var out = {
response: responses.toString('base64')
};
cache[id] = out;
res.end(JSON.stringify(out));
});
});
});