Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.DSI.PkixRequestCertGenerator

Feature notes: PKIX / CMS implementation notes

Classes, interfaces and records

classeCertificateFromRequest

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)

classeCertificateRequestPolicy

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)

classTstRequestCertificateGenerator

inherits from TstBaseCertificateGenerator

constructor Create(AOwner: TComponent); override;
Standard component constructor. There is no CertificateDone override any more: TstBaseCertificateGenerator.CertificateDone already IS DoCertificateDone, so OnCertificateDone is reached directly. It DOES set DefaultSecurityStrength, which the ancestor this component was rebased off used to set; see the body. Applications normally drop the component on a form rather than calling this directly.
procedure Execute(const aRequest: iCertificationRequest; aInfo : TObject = nil); overload;
Issue a certificate from aRequest. This is the entry point: the request is per-invocation DATA, not a design-time association, so it is a parameter and not a published property - it arrives at runtime from a socket or a file, cannot be streamed to a .dfm, and a property would leave a stale reques... Full description »
property Request: iCertificationRequest read fRequest;
The request being issued from, valid only for the duration of Execute and nil outside it. Read it from a handler that needs more of the request than its own parameters carry.
property AcceptedExtensions: tExtnValues read fAcceptedExtensions;
The extension kinds copied out of the request into the certificate, and the kinds an abvOmit verdict removed. Full description »
property OmittedExtensions: tExtnValues read fOmittedExtensions; function IgnoredItemNames: string;
The extensions and attributes the request asked for and did not get, by name where stOIDs knows one and by OID otherwise, comma separated; empty when the requester got everything it asked for. Full description »
class function KeyUsageText(const aKeyUsage: tKeyUsage): string;
The nine bits in RFC 5280 order, '+' separated, or '(none)'. The half that makes a refusal actionable: a requester told which bit disagreed can fix its enrolment client, one told only that something disagreed cannot.
class function PermittedKeyUsage(aAlgorithm: tEncapsulatedPublicKeyEnum; aForCA : Boolean; out aPermitted: tKeyUsage): tKeyUsageBasis;
The most a subject key of aAlgorithm may be given. See the table in the body for the citation of every row. A kubUnknown result means the table has no row - aPermitted is [] and says NOTHING; the caller applies the structural rules only.
class function AlgorithmCanSign(aAlgorithm: tEncapsulatedPublicKeyEnum; out aKnown : Boolean): Boolean;
True when a key of this kind can produce a signature at all. aKnown is False for an algorithm the table does not model, and a caller must not refuse on a False result when aKnown is False.
class function CheckKeyUsageCoherence(aAlgorithm: tEncapsulatedPublicKeyEnum; const aKeyUsage : tKeyUsage; aForCA : Boolean; out aReason : string): Boolean;
The four structural rules of RFC 5280 4.2.1.3, then the per-algorithm table. aReason names the offending bits and the most the key may have.
class function SubjectPublicKeyBits(const aPublicKey: iSubjectPublicKeyInfo): OctetString;
The octets RFC 5280 4.2.1.2 hashes: the VALUE of the subjectPublicKey BIT STRING, tag, length and unused-bits octet excluded. NOT the same bytes iMPPublicKey.PublicKeyIdentifier hashes for an EC, EdDSA or post-quantum key; see the body.
class function CheckSubjectKeyIdentifierCoherence(const aPublicKey: iSubjectPublicKeyInfo; const aValue : OctetString; out aReason : string): Boolean;
True when aValue is an identifier OF aPublicKey under one of a closed, named list of conventions - not merely when it equals the one this CA would have written.
class function ExtensionsRequestedBy(const aRequest: iCertificationRequest): iExtensions;
The extensions aRequest asks for, or nil. The class form of the protected RequestedExtensions, so a requester-side self-check reads the request the same way the CA does.
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;
The whole-request form, for a caller holding nothing but a request - an RA screening a queue, or an enrolment client self-checking before it sends. A request that restates NEITHER value is coherent: the accepted set is a permission, not a requirement.
property AcceptRequestedExtensions: tExtnValues read fAcceptRequestedExtensions write SetAcceptRequestedExtensions default cDefaultAcceptRequestedExtensions;
THE EXTENSION KINDS WHOSE REQUESTED VALUE THIS COMPONENT TAKES WITHOUT A HANDLER SAYING SO - the only kinds for which the no-handler verdict is rqvAccept rather than rqvIgnore. Full description »
property RefuseUnhandledRequestItems: Boolean read fRefuseUnhandledRequestItems write fRefuseUnhandledRequestItems default False;
When False (the default) an item NO HANDLER IS ATTACHED FOR and NO PROPERTY SPEAKS FOR is IGNORED: it does not reach the certificate, and it is named in IgnoredItemNames. Full description »
property OnCheckRequestSignature: tRequestSignatureEvent read fOnCheckRequestSignature write fOnCheckRequestSignature;
With no handler attached the proof of possession is verified and a FAILED verification REFUSES. That is the one hard default in this component: it costs nothing legitimate, and without it a requester could obtain a certificate over a stranger's public key.
property OnCheckRequestPublicKey: tRequestPublicKeyEvent read fOnCheckRequestPublicKey write fOnCheckRequestPublicKey;
With no handler attached the requested public key is ACCEPTED - it is the point of the request, and the alternative is a component that cannot issue.
property OnCheckRequestSubject: tRequestSubjectEvent read fOnCheckRequestSubject write fOnCheckRequestSubject;
With no handler attached the verdict is rqvAccept when SubjectNameAttributes is EMPTY and rqvIgnore when it is not. That is not a coin toss: a consumer that populated the collection has said at design time what the subject is to be, and a request must not override a design-time decision; a consumer that left it empty has said nothing, and the request's subject is the only name on offer.
property OnCheckRequestExtension: tRequestExtensionEvent read fOnCheckRequestExtension write fOnCheckRequestExtension;
With no handler attached the verdict is the one AcceptRequestedExtensions seeds: rqvAccept for a kind that property names, rqvIgnore (or a refusal when RefuseUnhandledRequestItems) for every other. Full description »
property OnRequestExtensionMissing: tMissingExtensionEvent read fOnRequestExtensionMissing write fOnRequestExtensionMissing;
With no handler attached the verdict is abvSupply - the component composes the extension itself, which is what it would have done with no request at all.
property OnCheckRequestAttribute: tRequestAttributeEvent read fOnCheckRequestAttribute write fOnCheckRequestAttribute;
With no handler attached the verdict is rqvIgnore (or a refusal when RefuseUnhandledRequestItems). A challenge password nobody checks is a challenge password nobody checked - it is named in IgnoredItemNames rather than quietly treated as satisfied.

Types (enumerations, sets, aliases)

typeiCertificationRequest

Alias - so a consumer needs one unit in its uses clause, not four. Same idiom as StreamSec.DSI.PkixCertGenerator's own iCertificate alias.

  iCertificationRequest = StreamSec.DSI.Pkcs10.iCertificationRequest;

typeiCertificationRequestInfo

  iCertificationRequestInfo = StreamSec.DSI.Pkcs10.iCertificationRequestInfo;

enumtRequestVerdict

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.

  tRequestVerdict = (rqvAccept,
                     rqvIgnore,
                     rqvRefuse);

enumtAbsentVerdict

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.

  tAbsentVerdict = (abvSupply,
                    abvOmit,
                    abvRefuse);

enumtKeyUsageBasis

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.

  tKeyUsageBasis = (kubUnknown,
                    kubProhibited,
                    kubInferred);

proctRequestSignatureEvent

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.

  tRequestSignatureEvent = procedure (Sender  : TObject;
                                      aInfo   : TObject;
                                const aRequest: iCertificationRequest;
                                      aValid  : Boolean;
                                const aReason : string;
                                  var aVerdict: tRequestVerdict) of object;

proctRequestPublicKeyEvent

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.

  tRequestPublicKeyEvent = procedure (Sender    : TObject;
                                      aInfo     : TObject;
                                const aRequest  : iCertificationRequest;
                                const aPublicKey: iSubjectPublicKeyInfo;
                                      aAlgorithm: tEncapsulatedPublicKeyEnum;
                                  var aAccept   : Boolean) of object;

proctRequestSubjectEvent

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.

  tRequestSubjectEvent = procedure (Sender    : TObject;
                                    aInfo     : TObject;
                              const aRequest  : iCertificationRequest;
                              const aRequested: iRDNSequence;
                                var aVerdict  : tRequestVerdict) of object;

proctRequestExtensionEvent

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.

  tRequestExtensionEvent = procedure (Sender    : TObject;
                                      aInfo     : TObject;
                                const aRequest  : iCertificationRequest;
                                const aExtension: iExtension;
                                      aExtnKind : tExtnValueEnum;
                                const aExtnId   : ObjectIdentifier;
                                  var aVerdict  : tRequestVerdict) of object;

proctMissingExtensionEvent

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.

  tMissingExtensionEvent = procedure (Sender   : TObject;
                                      aInfo    : TObject;
                                const aRequest : iCertificationRequest;
                                      aExtnKind: tExtnValueEnum;
                                  var aVerdict : tAbsentVerdict) of object;

proctRequestAttributeEvent

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.

  tRequestAttributeEvent = procedure (Sender    : TObject;
                                      aInfo     : TObject;
                                const aRequest  : iCertificationRequest;
                                const aAttribute: iCRIAttribute;
                                      aAttrKind : tCRIAttributeTypeEnum;
                                const aAttrId   : ObjectIdentifier;
                                  var aVerdict  : tRequestVerdict) of object;