Feature notes: PKIX / CMS implementation notes
inherits from eCertificateGenerator
Raised when a certification request is REFUSED, or cannot be issued from at all: a handler answered rqvRefuse / abvRefuse, the proof of possession did not verify, the request carries a public key of a kind this library does not model, or the inherited Execute was entered with no request in hand. Descends from eCertificateGenerator (and so from eSecComp), so a caller that already catches generator faults keeps catching these, and one that wants to tell a REFUSAL apart from "the CA could not sign" catches this class alone. The message always names the offending item - an extension by name or OID, an attribute by OID - because a refusal the requester cannot act on is only marginally better than silence.
(no public members)
inherits from eCertificateGenerator
Raised when this COMPONENT is configured to do something it must not do - today, an AcceptRequestedExtensions naming an extension from cCaComposedExtensions. Deliberately NOT eCertificateFromRequest: a refused request is a fact about the request and the requester may be told about it, whereas this is a fact about the CA's own setup and no requester should ever see its message. It is raised by the property SETTER, so a mis-tick in the Object Inspector fails at design time and a hand-edited .dfm fails at form load, rather than at the first request that exploits it.
(no public members)
inherits from TstBaseCertificateGenerator
constructor Create(AOwner: TComponent); override;
procedure Execute(const aRequest: iCertificationRequest; aInfo : TObject = nil); overload;
property Request: iCertificationRequest read fRequest;
property AcceptedExtensions: tExtnValues read fAcceptedExtensions;
property OmittedExtensions: tExtnValues read fOmittedExtensions;
function IgnoredItemNames: string;
class function KeyUsageText(const aKeyUsage: tKeyUsage): string;
class function PermittedKeyUsage(aAlgorithm: tEncapsulatedPublicKeyEnum; aForCA : Boolean; out aPermitted: tKeyUsage): tKeyUsageBasis;
class function AlgorithmCanSign(aAlgorithm: tEncapsulatedPublicKeyEnum; out aKnown : Boolean): Boolean;
class function CheckKeyUsageCoherence(aAlgorithm: tEncapsulatedPublicKeyEnum; const aKeyUsage : tKeyUsage; aForCA : Boolean; out aReason : string): Boolean;
class function SubjectPublicKeyBits(const aPublicKey: iSubjectPublicKeyInfo): OctetString;
class function CheckSubjectKeyIdentifierCoherence(const aPublicKey: iSubjectPublicKeyInfo; const aValue : OctetString; out aReason : string): Boolean;
class function ExtensionsRequestedBy(const aRequest: iCertificationRequest): iExtensions;
class function RequestedKeyUsage(const aRequest: iCertificationRequest; out aValue : tKeyUsage): Boolean;
class function RequestedSubjectKeyIdentifier(const aRequest: iCertificationRequest; out aValue : OctetString): Boolean;
class function CheckRequestCoherence(const aRequest: iCertificationRequest; aForCA : Boolean; out aReason : string): Boolean;
property AcceptRequestedExtensions: tExtnValues read fAcceptRequestedExtensions write SetAcceptRequestedExtensions default cDefaultAcceptRequestedExtensions;
property RefuseUnhandledRequestItems: Boolean read fRefuseUnhandledRequestItems write fRefuseUnhandledRequestItems default False;
property OnCheckRequestSignature: tRequestSignatureEvent read fOnCheckRequestSignature write fOnCheckRequestSignature;
property OnCheckRequestPublicKey: tRequestPublicKeyEvent read fOnCheckRequestPublicKey write fOnCheckRequestPublicKey;
property OnCheckRequestSubject: tRequestSubjectEvent read fOnCheckRequestSubject write fOnCheckRequestSubject;
property OnCheckRequestExtension: tRequestExtensionEvent read fOnCheckRequestExtension write fOnCheckRequestExtension;
property OnRequestExtensionMissing: tMissingExtensionEvent read fOnRequestExtensionMissing write fOnRequestExtensionMissing;
property OnCheckRequestAttribute: tRequestAttributeEvent read fOnCheckRequestAttribute write fOnCheckRequestAttribute;
Alias - so a consumer needs one unit in its uses clause, not four. Same idiom as StreamSec.DSI.PkixCertGenerator's own iCertificate alias.
The verdict on something the request DOES carry. Three outcomes, so this is an enumeration and not a Boolean.
rqvAccept - take it: the requested item becomes part of the certificate (an extension is copied, criticality and all; the requested subject becomes the certificate subject; an attribute is recorded as consumed by the CA).
rqvIgnore - do not take it, but issue anyway: the certificate is composed from the component's own Extensions / SubjectNameAttributes exactly as if the request had not asked. The requester does NOT get what it asked for, and the item is named in IgnoredItemNames.
rqvRefuse - issue nothing. Aborts before a serial is drawn or the issuer private key is touched, and raises eCertificateFromRequest naming the item.
The verdict on something the CA expected and the request does NOT carry - the other half of "based on what is in the certification request or not".
abvSupply - the component composes the extension itself, exactly as TstCertificateGenerator does with no request at all (ImposeExtnKeyUsage and friends, then OnGetExtensions).
abvOmit - the extension is left out: the kind is removed from the aToBeSet the pipeline works from, so neither the default imposition nor OnGetExtensions will see it.
abvRefuse - issue nothing, on the ground that this CA required the requester to ask for it. Raises eCertificateFromRequest.
How much weight a per-algorithm keyUsage rule carries. It decides how a refusal is WORDED and nothing else - the refusal is the same either way.
kubProhibited - the profile states a MUST NOT list or an explicit "only". The message may name the document.
kubInferred - the profile states a MAY-list only, or nothing at all, and the exclusion follows from what the algorithm can do. The message says the KEY CANNOT PERFORM the bit; it must never claim an RFC forbids what that RFC merely omits. RFC 8410 s5 contains no MUST NOT anywhere, and epRw / epNr / epEcnr hang off StreamSec's own id_ssa arc with no IETF profile.
kubUnknown - the table has no row for this algorithm. aPermitted is [] and MUST NOT be read as a rule; see PermittedKeyUsage.
OnCheckRequestSignature reports the result of verifying the request's own self-signature - the PKCS#10 proof of possession. aValid and aReason are IN parameters on purpose: a handler that could set aValid to True would be able to issue over a public key nobody proved possession of. What a handler CAN do is refuse a request whose signature verified (a CA that additionally demands a particular signature algorithm), or - answering rqvIgnore - issue despite one that did not, which exists because RFC 4211 / CMP allow possession to be proved out of band by a registration token or a challenge. rqvIgnore is the ONLY answer that excuses a failed verification; rqvAccept on an invalid signature still refuses, because "take it" is not a coherent thing to say about a signature that does not verify. Remember what the signature proves: that whoever composed the request holds the matching private key, and NOTHING about the subject name.
OnCheckRequestPublicKey offers the public key the requester wants certified. Two outcomes only - a certificate without a public key does not exist - so this one is a Boolean and not a verdict. A handler refuses a key that is too short, of an algorithm this CA does not certify, or on a list of known compromised keys. It CANNOT substitute a different key: aPublicKey is const and there is no var key parameter, because a CA that swapped the key would issue a certificate the requester cannot use and for which no possession was proved. aAlgorithm is aPublicKey.subjectPublicKey.Choice, already read out; it is never epUndefined here, because a request whose key algorithm this library does not model is refused before this event fires.
OnCheckRequestSubject offers the subject name the requester asked for. aRequested is the parsed request's own RDN sequence: READ ONLY in the strong sense - a loaded tSigned keeps its structure read-only so its DER stays byte-exact for signature verification, and writes through it do not take and do not raise. On rqvAccept the requested RDNs are copied into the certificate's subject and the SubjectNameAttributes collection then runs on top of them, so a CA can take the request's O= and overwrite its CN=. On rqvIgnore the requested name is discarded and the subject is whatever SubjectNameAttributes / OnGetSubjectNameAttribute build. To compose a name with the certificate in hand, use the family's existing OnGetSubjectName, which fires later and receives the writable certificate.
OnCheckRequestExtension fires once for EVERY extension carried in the request's pkcs-9-at-extensionRequest attribute, in encoding order, before anything with a side effect has happened.
BOTH aExtnKind AND aExtnId are passed, and using only the first is a mistake: aExtnKind is aExtension.extnValue.Choice, and it is evUndefined for every extension this library does not model - which is precisely the case where the CA has to decide for itself, and the only handle it has then is the raw OID.
The handler may READ the requested value (aExtension.critical, and aExtension.extnValue.AsCeXxx) but may not edit it - same read-only structure as above. To issue a DIFFERENT value than the one requested, answer rqvIgnore here and write the value you want in OnGetExtensions, which fires later and holds the certificate's own writable iExtensions. Inspection here, composition there.
rqvAccept copies the extension into the certificate verbatim, criticality included, and SUPPRESSES the component's own imposition of that kind. It is the one verdict that is not available for an extension this library does not model: aExtnKind = evUndefined has no CHOICE alternative to select, so rqvAccept on one REFUSES the request naming the OID rather than issuing a certificate no encoder will take. rqvIgnore and rqvRefuse work on it normally.
OnRequestExtensionMissing fires once for every member of the Extensions property that the request does NOT carry - after every OnCheckRequestExtension, so a handler has seen the whole picture of what was asked before being asked about what was not. The expected set is the consumer's own Extensions property (seeded by CertificateWizard), never a list of "extensions a request must carry" baked into this library: a different CA legitimately expects a different set, or none. Use it to catch a requester that omits keyUsage hoping to be given the CA's generous default rather than the constrained usage its registration entitles it to.
OnCheckRequestAttribute fires once for every attribute in certificationRequestInfo.attributes EXCEPT pkcs-9-at-extensionRequest, whose contents are reported one extension at a time by OnCheckRequestExtension - reporting it both whole and per member would let a handler accept the container and refuse a member, or the reverse. So this covers challengePassword, id-regCtrl-regToken, the statementOfPossession, and every attribute type this library does not model (aAttrKind = ctUndefined, which is again why aAttrId is passed alongside).
rqvAccept means the CA has consumed the attribute and is satisfied - a matching challenge password, a valid registration token. NOTHING is copied into the certificate: a PKCS#10 attribute is not a certificate field and there is no defined mapping from an arbitrary attribute to certificate content.
A handler that goes looking for a second attribute by itself must walk Items[] / value[] and NEVER UniqueItems[] / valueUnique[]: those are find-or-ADD, the add half is correctly refused on a loaded request, and they return NIL rather than raising - so `if Assigned(x) then <read>` reads nothing, in silence, and a check written that way admits everything.