OpenPKCS12

security and signatures

Description

Opens a PKCS #12 container held in memory and installs its private key, certificate and CA chain as the signing identity. The container must be the complete DER encoding of one PFX with no trailing data, and the password must decrypt it and validate its integrity. The key must match the certificate; a container without a matching pair is rejected.

The call replaces any identity already open, and a failed open leaves the identity cleared rather than keeping the previous one. On success CertificateDER holds the DER encoding of the signing certificate, and the chain from the container is embedded in the CMS signatures and OCSP requests the identity produces.

Syntax

Delphi

function TPDFNativeSigningIdentity.OpenPKCS12(const Data, Password: AnsiString; out ErrorText: WideString): Boolean;

Parameters

DataComplete DER-encoded PKCS #12 container; empty input or input above 16 MiB is rejected
PasswordContainer password; a password containing a NUL character is rejected
ErrorTextReceives an English diagnostic when the call fails

Return values

TrueThe identity is open and ready for the Sign methods
FalseDecoding, password, integrity or key-matching validation failed; ErrorText describes the failure

Remarks

The identity is backed by an OpenSSL 3 signing library loaded at runtime; the class is functional on non-Windows Free Pascal targets, and on Windows targets the constructor itself raises a ENotSupportedException.

See also

NativeCMSSignedAttributes, GetNativeBackendCapabilities, TPDFlibPKCS11Client