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:
- Client connects to the server and sends an
'OCSPRequest'
to it (via status info extension in ClientHello). - Server receives the request and invokes the
'OCSPRequest'
event listener if present. - Server extracts the OCSP URL from either the
certificate
orissuer
and performs an OCSP request to the CA. - Server receives
OCSPResponse
from the CA and sends it back to the client via thecallback
argument - 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.
Please login to continue.