Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.DSI.PkixKeyFilter

Feature notes: PKIX / CMS implementation notes

Classes, interfaces and records

classTstCustomKeyFilterCRL

inherits from TstAbstractKeyFilter

implements iSaveable

constructor Create(AOwner: TComponent); override;
Constructor. Sets the revocation defaults (RevocationPolicy = rpSoftFail, CRLClockSkew = 300 s) and the internal sorted CRL list. Applications rarely call this directly; the filter is normally dropped onto the same owner as a KeyManager and wired up through the published properties. » member page
destructor Destroy; override;
Destructor; releases the loaded-CRL list. Internal lifetime management - applications do not call this directly. » member page
function IsKeyAllowed(const aIdentifier: OctetString; const aKey : iUnknown) : Boolean; override;
Called by the KeyManager during certificate-chain validation to decide whether the key backing aCert is still acceptable. Full description »
procedure LoadCRL(const aFileName: string; const aExpectedIssuer: iCertificate = nil);
Loads a single DER-encoded CRL file, verifies its signature against the issuing CA held in the KeyManager, enforces freshness per RevocationPolicy, indexes its revoked serials, and copies the file into Directory so it is re-loaded on the next PopulateKeyList. Full description »
function RemoveCRL(const aFileName: string): Boolean;
Removes a previously loaded CRL from the in-memory set so it is no longer written to the ini file's CRLS section on save. Full description »
function IsCRLFresh(const aCRL: iCertificateList): Boolean;
IsCRLFresh returns True iff aCRL is within its validity window in UTC: thisUpdate <= now <= nextUpdate, widened by CRLClockSkew seconds at both ends. Full description »
function HasFreshCRLFor(const aCACert: iCertificate): Boolean;
HasFreshCRLFor returns True iff this filter holds a still-fresh CRL issued by aCACert (matched by issuer name). Full description »
property FilterFileName;
Inherited. Path of the signed ini file that persists this filter's revocation state: the CRLS section lists the loaded CRL files and their thumbprints, and enabling the filter applies the revocations of the lists it goes on holding, whatever their file names. Full description »
property OnGenerateSignature;
Inherited. Fires when the filter's persisted ini file is being saved, so the application can sign the serialized filter state. Assign it (together with OnVerifySignature) to make the on-disk revocation store tamper-evident - loading a filter whose signature does not verify is a security-critical failure. » member page
property OnVerifySignature;
Inherited. Fires when the persisted ini file is being loaded, so the application can verify the signature produced by OnGenerateSignature and reject a modified revocation store. » member page
property Directory: string read GetDirectory write SetDirectory stored StoredDirectory;
Directory holding the CRL files this filter scans and loads (via PopulateKeyList / LoadCRL), and into which LoadCRL copies imported CRLs. Full description »
property FileFilter: string read GetFileFilter write SetFileFilter stored StoredFileFilter;
File mask used when scanning Directory for CRL files during PopulateKeyList. Defaults to '*.crl'. Override only if the CRLs use a different extension. » member page
property RevocationPolicy: TRevocationPolicy read fRevocationPolicy write fRevocationPolicy default rpSoftFail;
RevocationPolicy governs how an authentic CRL is treated at load. rpIgnore disables revocation loading unconditionally: no serials are indexed at all, expired or not. Full description »
property CRLClockSkew: Cardinal read fCRLClockSkew write fCRLClockSkew default 300;
CRLClockSkew (seconds) tolerates modest clock differences when applying the thisUpdate/nextUpdate freshness window. Default 300 (5 minutes). » member page
property OnFetchFreshCRL: TFetchFreshCRLEvent read fOnFetchFreshCRL write fOnFetchFreshCRL;
OnFetchFreshCRL fires when a CRL being loaded is authentic but expired, giving the application a chance to supply a fresh replacement before the RevocationPolicy is applied. Full description »

classTstKeyFilterCRL — component reference

inherits from TstCustomKeyFilterCRL

(no public members)

classtKeyFilterCRL

inherits from TstCustomKeyFilterCRL

class function Description: string; override;
Returns the value of rsUseKeyFilterCRLFor.

classTstCustomKeyFilterChain

inherits from TstAbstractKeyFilter

implements iSaveable

constructor Create(AOwner: TComponent); override;
Standard component constructor. An application rarely calls this directly: it drops a TstKeyFilterChain onto the form/data module alongside the KeyManager and lets the streaming system construct it. It seeds the trust defaults - CacheCACertificates True, CacheEndEntityCertificates False, CheckValidityDate True - and the internal explicitly-trusted list. » member page
destructor Destroy; override;
Releases the explicitly-trusted list, the accepted-policies list and the re-entrancy guard. Internal teardown; applications do not call it. » member page
function IsKeyAllowed(const aIdentifier: OctetString; const aKey : iUnknown) : Boolean; override;
Filter hook the KeyManager invokes for every key it is about to hand out (e.g. when TLS/CMS asks for a peer certificate). Full description »
function CheckCertificate(const aCert: iCertificate): Boolean; overload;
CheckCertificate is the main entry point an application calls to validate a certificate against this filter's configured trust anchors (TrustedKeys) and any cached, previously-verified CA certificates. Full description »
function CheckCertificate(const aCert : iCertificate; var aErrorCodes: tPkixCertVerificationErrors) : Boolean; overload;
Same validation as CheckCertificate(aCert), but returns the machine-readable failure reasons in aErrorCodes (e.g. pcvExpired, pcvIssuerNotTrusted, pcvConstraintFaultNameConstraints). Full description »
function CheckCertificate(const aCert : iCertificate; var aErrorMsg: string) : Boolean; overload;
Same validation, returning a human-readable, possibly multi-line failure description in aErrorMsg - suitable for logging or display to an operator. » member page
function CheckCertificate(const aCert : iCertificate; var aErrorCodes: tPkixCertVerificationErrors; var aErrorMsg : string) : Boolean; overload;
Same validation, returning BOTH the error-code set and the human-readable message. This is the overload the other overloads ultimately delegate to, and it honours the CheckValidityDate property to decide whether an expired certificate fails. » member page
function CheckCertificate(const aCert : iCertificate; var aErrorCodes : tPkixCertVerificationErrors; var aErrorMsg : string; aAllowExpired: Boolean) : Boolean; overload;
Full-control overload: aAllowExpired forces the validity-date behaviour for this one call regardless of the CheckValidityDate property (pass True to accept an otherwise-valid but expired certificate, e.g. when re-validating an archived signature at its original signing time). All other trust, signature and constraint checks still apply. » member page
function FindCACertificate(const aCert: iCertificate): iCertificate;
Returns the issuer (CA) certificate for aCert found among the KeyManager's keys (its trust anchors and any cached CA certificates), or aCert itself if it is self-issued (issuer name equals subject name), or nil if no matching signature-verified issuer is known here. Full description »
function IsExplicitlyTrusted(const aCert: iCertificate): Boolean;
Returns True if aCert is (or is cached as) an explicitly trusted anchor - i.e. it lives in one of the TrustedKeys indexes, or was previously verified and cached as trusted. An application can call this to short-circuit its own logic for a certificate it already knows the filter trusts. » member page
function IsExplicitlyNotTrusted(const aCert: iCertificate): Boolean;
Returns True if aCert is currently on this filter's forbidden list (the identifiers it actively rejects, e.g. certificates that failed a previous check while AutoCheckNotTrusted was off). An application can use it to test whether a certificate has already been black-listed by this filter. » member page
property FilterFileName;
Path of the ini file this filter persists its state to (the set of explicitly-trusted identifiers it has cached). Set it when the trust decisions must survive across runs; leave it empty for an in-memory filter that rebuilds its trust from TrustedKeys each time. » member page
property OnGenerateSignature;
Optional hook to sign the persisted filter file (FilterFileName) when it is saved, giving it tamper protection. The save path (SaveToStream) calls this to sign the serialized trust state; an application that persists trust state should pair OnGenerateSignature with OnVerifySignature so the load path rejects an edited file. » member page
property OnVerifySignature;
Companion to OnGenerateSignature: verifies the signature over the persisted filter file when it is loaded, so a hand-edited trust file is detected and refused. Assign the matching verifier whenever OnGenerateSignature is used. » member page
property CheckValidityDate: Boolean read fCheckValidityDate write SetCheckValidityDate;
When True (the default), CheckCertificate fails a certificate whose validity window has passed (adding pcvExpired). Set it False to make expiry a reported-but-non-fatal condition - useful when verifying archived signatures whose certificates have since expired. Individual calls can override this via the aAllowExpired overload of CheckCertificate. » member page
property AcceptedPolicies: TStrings read fAcceptedPolicies write SetAcceptedPolicies;
AcceptedPolicies lists the certificate policy OIDs the caller is willing to accept. When non-empty (and not just anyPolicy), a certificate is rejected unless one of its policies - possibly reached through the CA policy mappings
- appears here. When empty, policy processing imposes no restriction. » member page
property TrustedKeys: tDSIKeyStoreOptionList read fTrustedKeys write SetTrustedKeys;
TrustedKeys selects which of the KeyManager's key indexes hold this filter's trust anchors - the root/CA certificates a chain must terminate at to be accepted. This is the primary configuration step: an application populates a key index (store) with its trusted roots and then ticks that index here. A certificate whose chain does not reach a key found via a TrustedKeys index is rejected. » member page
property AutoCheckNotTrusted: Boolean read fAutoCheckNotTrusted write SetAutoCheckNotTrusted;
AutoCheckNotTrusted changes how a failed certificate is remembered. When False (the default), a certificate that fails verification is added to this filter's forbidden list so it is rejected outright next time without re-running the full check. Full description »
property CacheCACertificates: Boolean read fCacheCACertificates write SetCacheCACertificates;
CacheCACertificates (default True) lets the filter remember CA certificates it has already verified so intermediate chains are not re-validated on every call. Turning it off forces a full re-walk each time at the cost of speed. Setting it False also forces CacheEndEntityCertificates off. » member page
property CacheEndEntityCertificates: Boolean read fCacheEndEntityCertificates write SetCacheEndEntityCertificates;
CacheEndEntityCertificates (default False) additionally caches verified leaf (end-entity) certificates as trusted, not just CAs. Enable it when the same end-entity certificates recur and you want to skip re-verifying them; it implies CacheCACertificates and turns it on automatically. Leave it off if leaf trust must be re-evaluated every time. » member page
property OnInvalidCertificate: tSignatureVerificationFailureEvent read fOnInvalidCertificate write SetOnInvalidCertificate;
OnInvalidCertificate might be triggered by CheckCertificate at three stages: * If the certificate has expired and CheckValidityDate is True. Full description »

classTstKeyFilterChain — component reference

inherits from TstCustomKeyFilterChain

(no public members)

classtKeyFilterChain

inherits from TstCustomKeyFilterChain

class function Description: string; override;

Types (enumerations, sets, aliases)

procTFetchFreshCRLEvent

TFetchFreshCRLEvent lets an application supply a replacement when the CRL filter detects that a loaded CRL has passed its nextUpdate. The filter itself stays free of any network/TLS dependency: the handler decides how to obtain a fresh CRL (typically StreamSec.DSI.AbstractOcsp.FetchCRL against the CA's cRLDistributionPoints URI) and returns it in aFreshCRL, or leaves it nil to decline. Used identically client-side (during verification) and server-side (the OCSP responder shares this filter as its revocation source).

  TFetchFreshCRLEvent = procedure(Sender          : TObject;
                                  const aStaleCRL : iCertificateList;
                                  const aCACert   : iCertificate;
                                    out aFreshCRL : iCertificateList) of object;

proctSignatureVerificationFailureEvent

  tSignatureVerificationFailureEvent = procedure (Sender        : TObject;
                                            const aCert,
                                                  aCACert       : iCertificate;
                                            const aErrorMsg     : string;
                                            const aErrorCodes   : tPkixCertVerificationErrors;
                                              var aExplicitTrust: Boolean) of object;

Routines