OpenPKCS11

Security and signatures

Description

Adopts a PKCS #11 token identity, such as a smart card or HSM key reached through TPDFlibExternalSigningKey, for signing OCSP requests. The client is referenced, not owned: it must outlive the identity. The client is connected when it is not connected yet, and its key must be an RSA, ECDSA or EdDSA key with a certificate selected.

The certificate must be exactly one complete DER certificate, the chain is limited to fewer than 1024 certificates, and the certificate together with the chain must stay within 64 KiB. The chain certificates are sent with every signed OCSP request the identity produces.

A token identity signs OCSP requests through the client; the CMS Sign methods need a software identity opened with OpenPKCS12.

Syntax

Delphi

function TPDFNativeSigningIdentity.OpenPKCS11(Client: TPDFlibExternalSigningKey; const Chain: array of AnsiString; out ErrorText: WideString): Boolean;

Parameters

ClientConnected external signing client that selects the token key and certificate; nil is rejected
ChainDER-encoded CA certificates to send with signed requests
ErrorTextReceives an English diagnostic when the call fails

Return values

TrueThe token identity is open and SignOCSPRequest signs through it
FalseThe connection, key type, certificate or size validation failed; ErrorText describes the failure

Remarks

The call replaces any identity already open, releasing a previous software identity and its chain.

The class is functional on non-Windows Free Pascal targets; on Windows targets native signing is unavailable.

See also

TPDFlibExternalSigningKey, TPDFlibPKCS11Client, NativeOCSPSignedRequests