Skip to content

Commit

Permalink
readme: fixed cache example
Browse files Browse the repository at this point in the history
- Handle missing URI
- Look up cached response

fix #11
fix #10
fix #15
  • Loading branch information
sebdeckers authored and indutny committed Nov 10, 2017
1 parent c831fd3 commit 1dc3b23
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions README.md
Expand Up @@ -62,16 +62,21 @@ var server = https.createServer({

server.on('OCSPRequest', function(cert, issuer, cb) {
ocsp.getOCSPURI(cert, function(err, uri) {
if (err)
return cb(err);
if (err) return cb(err);
if (uri === null) return cb();

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

cache.request(req.id, options, cb);
var options = {
url: uri,
ocsp: req.data
};

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

0 comments on commit 1dc3b23

Please sign in to comment.