PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
This guide applies to version 3.2.1 of the native ComPDF SDK for iOS, which requires iOS 15 or later. Choose your workflow based on who holds the private key and what the signer returns:
.p12 or .pfx file and its password.CPDFDeferredSignSession, prepare the PDF, pass the prepared digest to the signer, and fill the result into the same prepared PDF. Pass a raw signature value as signatureValue for the SDK to build the CMS container, or pass a complete detached CMS container as containerDER to embed it. Use DocumentDigest mode for the complete-container path. SignedAttributes mode requires the raw-signature path.| Signature algorithm | Local PKCS#12 signing | Two-step: raw signature value | Two-step: complete CMS | Test certificate generation |
|---|---|---|---|---|
| RSA-PKCS#1 v1.5 | Supported | Supported | Embed the signer's detached CMS | RSA-2048 |
ECDSA P-256 with SHA-256 (SHA256WithECDSA) | Confirmed in the core library; not confirmed with the iOS 3.2.1 release package | Confirmed in the core library; pass a DER signature value. Not confirmed with the iOS 3.2.1 release package | Embed the signer's detached CMS; iOS 3.2.1 release-package verification is unconfirmed | Not available for ECC |
| RSA-PSS | Not supported | Not supported | Container embedding is not RSA-PSS support; verification is unconfirmed | Not available |
ECDSA P-256: For local signing, supply a PKCS#12 file with the P-256 certificate and matching private key. For raw-signature fill, the iOS API contract requires an ASN.1 DER-encoded SEQUENCE { r, s }, not the fixed-width r‖s format (IEEE P1363). This DER encoding is for the signature value, not the certificate or the CMS container. The core-library confirmation is for P-256 with SHA-256; it does not establish support for other ECDSA curves or digest combinations.
RSA-PSS: Do not select RSA-PSS for local signing or two-step raw-signature assembly. An RSA-PSS enum in the external signing API, or successful embedding of a CMS container, does not establish that iOS can create or verify an RSA-PSS signature.
Test certificates: CPDFSignature.generatePKCS12Cert generates an RSA-2048 PKCS#12 test identity. It cannot generate an ECC test identity. See Create Digital Certificates.
The digest algorithm hashes the input; the signature algorithm uses a private key to sign. For two-step signing, use the digest algorithm selected during preparation for the signature value or detached CMS returned by the signer. hashToSign is already a binary digest; do not hash it again.
| Digest algorithm | Local PKCS#12 signing | Two-step preparation and fill | RFC 3161 timestamp request |
|---|---|---|---|
| SHA-256 | Supported | Supported (default) | Supported (default) |
| SHA-384 | Not supported | Supported | Supported |
| SHA-512 | Not supported | Supported | Supported |
The two-step column describes digest selection for the raw-signature and complete-container paths, not every combination of digest, signature algorithm, and key type. The timestamp column describes the message imprint sent via CPDFTimestampService and CPDFTimestampOptions.digestAlgorithm, not the algorithm the TSA uses to sign its response, nor the digest of a local PKCS#12 signature. See Timestamped Signatures.
| Input | Where to use it |
|---|---|
PKCS#12 (.p12, .pfx) | Local signing: pass the file containing the signing certificate and its private key, plus the password. |
| A single DER-encoded X.509 certificate | Two-step raw-signature fill: use signerCertificateDER. Supply it during preparation in SignedAttributes mode; in DocumentDigest mode, you can supply it at fill time if it was not provided during preparation. |
| X.509 certificate chain in DER | For raw-signature assembly, pass certificateChainDER as a list with one DER certificate per entry. Convert PEM certificates to binary DER for both DER properties. An embedded chain helps build a chain but does not make it trusted. |
| Detached CMS/PKCS#7 in DER | For complete-container fill, pass the DER SignedData container in containerDER. The signer supplies the CMS signature and relevant certificates. Do not pass a bare certificate, a PKCS#12 identity, or a raw signature here. |
| Raw signature value | For raw-signature fill, pass signatureValue: a modulus-sized byte block for RSA-PKCS#1 v1.5 or a DER SEQUENCE { r, s } for ECDSA. Provide certificates separately. |
| Trust anchors for validation | For the structured validation report, set CPDFSignatureValidationOptions.trustedCertificatePath to a PEM bundle or an OpenSSL-style hashed certificate directory. When building a chain separately, CPDFCertificateStore accepts DER bytes via addTrustedCertificateDER: or a PEM/DER certificate file via addTrustedCertificateFileAtPath:. These inputs do not contain a signing private key. |
Always verify the output PDF after signing or embedding a container. Check signature integrity and signed-content coverage separately from certificate-chain trust. A successful fill, even one that checks the CMS messageDigest attribute, is not a substitute for signature verification.
An earlier iOS simulator smoke test covered RSA-PKCS#1 v1.5 two-step signing and reopening the PDF to verify it: SHA-256 raw-signature and complete-container paths, and SHA-384/SHA-512 raw-signature paths. This was not a test of the iOS 3.2.1 release package and does not establish certificate-chain trust. ECDSA P-256 support above is based on core-library confirmation and the iOS API contract, not an iOS end-to-end test. The timestamp digest options are exposed by the SDK; a TSA round trip has not been confirmed with the iOS 3.2.1 release package. Do not assume verification support for ECDSA, RSA-PSS, or arbitrary third-party CMS containers from the signing matrix.