Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable ocsp? #14

Closed
felixsanz opened this issue Jul 6, 2016 · 1 comment
Closed

How to enable ocsp? #14

felixsanz opened this issue Jul 6, 2016 · 1 comment

Comments

@felixsanz
Copy link

Sorry, noob here. I made a test on ssllabs.com and this says "OCSP stapling No"

What do i need to make it pass? Cache? Server? I don't fully understand what ssllabs tests here

@krzysdz
Copy link

krzysdz commented Aug 2, 2018

Just copy the code from https://github.com/indutny/ocsp#cache. I've copiedpasted it below with some comments.

const https = require('https');
const ocsp = require('ocsp');

// Create cache for OCSP (it'll be used to respond to OCSP stapling requests)
var cache = new ocsp.Cache();

// Create your HTTPS server
var server = https.createServer({
  cert: cert, // Your cert
  key: key // Your private key
}, function(req, res) {
  res.end('hello world'); // Your request handling and response
});

/*
 * This block below responds to OCSP sapling requests
 * 1. It gets OCSP URI for your certificate
 * 2. Checks if there is a valid cached response
 * 3. Sends cached response OR queries OCSP server (using OCSP URI) to get a response
 */
server.on('OCSPRequest', function(cert, issuer, cb) {
  ocsp.getOCSPURI(cert, function(err, uri) {
    if (err) return cb(err);
    if (uri === null) return cb();

    var req = ocsp.request.generate(cert, issuer);
    cache.probe(req.id, function(err, cached) {
      if (err) return cb(err);
      if (cached !== false) return cb(null, cached.response);

      var options = {
        url: uri,
        ocsp: req.data
      };

      cache.request(req.id, options, cb);
    });
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants