Feature notes: PKIX / CMS implementation notes
(no public members)
TOcspCacheEntry is one pre-produced, signed, nonce-less OCSPResponse held in the RFC 5019 lightweight-mode cache, keyed by the request CertID. It carries the stamped producedAt (== thisUpdate) and nextUpdate so the HTTP layer can emit Last-Modified / Expires / Cache-Control from it, plus a precomputed ETag. A record (value type) so the TDictionary manages its lifetime automatically.
RespDER: OctetString;
ProducedAtUTC: TDateTime;
NextUpdateUTC: TDateTime;
ETag: string;
inherits from TThread
TOcspListener is the private accept loop. It listens on the server Address / Port and dispatches each accepted connection to a TOcspConnThread worker, polling its Terminated flag so that Active := False stops it promptly. The accept loop never touches a client socket itself, so a slow or hostile client cannot stall it.
constructor Create(aServer: TstOcspServer);
inherits from TThread
TOcspConnThread services a single accepted connection off the accept loop, so one slow or malicious client cannot block the responder from answering everyone else. It is FreeOnTerminate and decrements the server's active- connection counter when it exits. The connection is owned by the worker: the worker closes and frees it.
constructor Create(aServer: TstOcspServer; aConn: tAbstractSocket);
inherits from TComponent
TstOcspServer
OCSP responder component. Configure CertificateManager, Index, CRLFilter, Address and Port, then set Active to True.
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function ProcessRequest(const aRequestDER: OctetString): OctetString; virtual;
procedure FlushCache;
property Active: Boolean read FActive write SetActive default False;
property Address: string read FAddress write FAddress;
property Port: Word read FPort write FPort default 80;
property CertificateManager: TstCustomCertificateManager read FCertificateManager write SetCertificateManager;
property CACertificate: iCertificate read FCACert write FCACert;
property Index: TstBaseKeyIndexCertUnique read FIndex write SetIndex;
property CRLFilter: TstCustomKeyFilterCRL read FCRLFilter write SetCRLFilter;
property ResponderCertificate: iCertificate read FResponderCert write FResponderCert;
property ResponderKey: IInterface read FResponderKey write FResponderKey;
property OnCheckAuthority: tOcspAuthorityEvent read FOnCheckAuthority write FOnCheckAuthority;
property ResponseValidity: Cardinal read FResponseValidity write FResponseValidity default 3600;
property Nonce: Boolean read FNonce write FNonce default True;
property Timeout: Cardinal read FTimeout write FTimeout default 15000;
property MaxConnections: Integer read FMaxConnections write FMaxConnections default 64;
property LightweightMode: TOcspLightweightMode read FLightweightMode write SetLightweightMode default olmDisabled;
TOcspLightweightMode selects the responder's RFC 5019 (Lightweight OCSP) policy. HTTP GET requests are decoded in every mode (transport is orthogonal); the mode only controls the RESPONSE style. A "lightweight" response is a pre-produced, nonce-less, cached BasicOCSPResponse with the RFC 5019 sec.6.2 HTTP caching headers; a "standard" response is freshly signed, echoes the request nonce if the request carries one and the Nonce property is set, and carries no caching headers. Only good/revoked answers are ever cacheable: an unknown or error answer is always built fresh with no caching headers, in EVERY mode. The mode decides, per request:
olmDisabled - always standard. (Default.)
olmAlways - lightweight for a good/revoked answer, standard otherwise; the request nonce is ignored (never echoed).
olmAsRequested - adaptive: a request that carries NO nonce is answered lightweight (if good/revoked); a request that carries a nonce is answered standard (fresh, nonce echoed) because it asked for freshness.
THE LAST WORD ON WHETHER THIS RESPONDER ANSWERS FOR THIS CERTIFICATE.
It is asked only AFTER the certificate has been found in the key manager, so aCert is never nil: a CertID naming something the manager does not hold was already refused, and no handler is consulted about it. aAuthoritative arrives True, so a handler that only wants to refuse some of what it holds need not restate the rule that got it here.
In principle the certificate manager is where this belongs - its stores, indexes and filters are what decide which certificates exist for this responder, and configuring them is the intended way to scope it. The event is for the policy that cannot be expressed as a store: a CA that publishes status for its sub-CAs and deliberately NOT for its end entities, say, where the right answer is a refusal rather than "unknown", because "unknown" invites the client to ask again for ever.