You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used wb with https and express. Still I get ocsp respond from the ocsp server even I enable ocsp stapling. How to enable it. I coud not figure out it.
This is my code.
var WebSocket = require('ws');
var https = require('https');
var ocsp = require('ocsp');
var bodyparser = require('body-parser');
var express = require('express');
var app = express();
app.use(bodyparser.json());
var PORT = 8080;
var ocspCache = new ocsp.Cache();
var server = new https.createServer({
cert: fs.readFileSync(`${__dirname}/pki/server/certs/server.cert.pem`),
key: fs.readFileSync(`${__dirname}/pki/server/private/server.key.pem`),
ca: [
fs.readFileSync(`${__dirname}/pki/intermediate/certs/ca-chain.cert.pem`)
],
requestCert: true,
rejectUnauthorized: true
}, app);
var wss = new WebSocket.Server({
server
});
wss.on('connection', function connection(ws, req) {
var cert = req.socket.getPeerCertificate(true);
var rawCert = cert.raw;
var rawIssuer = cert.issuerCertificate.raw;
ocsp.getOCSPURI(rawCert, function(err, uri) {
if (err) console.log(err);
var req = ocsp.request.generate(rawCert, rawIssuer);
var options = {
url: uri,
ocsp: req.data
};
ocspCache.request(req.id, options, null);
});
ws.on('message', function incoming(message) {
console.log(ocspCache.cache);
ocsp.check({cert: rawCert, issuer: rawIssuer}, function(err, res) {
if(err) {
console.log(err.message);
ws.send('Failed to obtain OCSP response!');
} else {
console.log(res.type);
var status = res.type;
if(status == 'good'){
console.log('Received: %s', message);
ws.send('Hello from server!');
}else{
ws.send('Certificate is revoked!');
}
}
});
});
});
server.listen(PORT, ()=>{
console.log( (new Date()) + " Server is listening on port " + PORT);
});
I used wb with https and express. Still I get ocsp respond from the ocsp server even I enable ocsp stapling. How to enable it. I coud not figure out it.
This is my code.
@indutny
The text was updated successfully, but these errors were encountered: