OCSPRequest event (tls.Server)

Event: 'OCSPRequest'

function (certificate, issuer, callback) { }

Emitted when the client sends a certificate status request. The server's current certificate can be parsed to obtain the OCSP URL and certificate ID; after obtaining an OCSP response callback(null, resp) is then invoked, where resp is a Buffer instance. Both certificate and issuer are Buffer DER-representations of the primary and issuer's certificates. They can be used to obtain the OCSP certificate ID and OCSP endpoint URL.

Alternatively, callback(null, null) may be called, meaning that there was no OCSP response.

Calling callback(err) will result in a socket.destroy(err) call.

Typical flow:

  1. Client connects to the server and sends an 'OCSPRequest' to it (via status info extension in ClientHello).
  2. Server receives the request and invokes the 'OCSPRequest' event listener if present.
  3. Server extracts the OCSP URL from either the certificate or issuer and performs an OCSP request to the CA.
  4. Server receives OCSPResponse from the CA and sends it back to the client via the callback argument
  5. Client validates the response and either destroys the socket or performs a handshake.

NOTE: issuer could be null if the certificate is self-signed or if the issuer is not in the root certificates list. (An issuer may be provided via the ca option.)

NOTE: adding this event listener will only have an effect on connections established after the addition of the event listener.

NOTE: An npm module like asn1.js may be used to parse the certificates.

doc_Nodejs
2016-04-30 04:40:39
Comments
Leave a Comment

Please login to continue.