How to use the asn1.js-rfc2560.OCSPRequest function in asn1

To help you get started, we’ve selected a few asn1 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indutny / ocsp / lib / ocsp / server.js View on Github external
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);
    });
  });
github indutny / ocsp / lib / ocsp / request.js View on Github external
} ],
    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
  };
};
github indutny / bud / test / fixtures.js View on Github external
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));
      });
    });
  });