Release history
pyHanko
0.35.1
Release date: 2026-05-06
Dependency changes
Bump
cryptographyto48.0.0.Relax upper bound for
uharfbuzzto<0.55.0.
New features and enhancements
Signing
Allow signing with ML-DSA
Validation
Allow validating ML-DSA signatures
0.35.0
Release date: 2026-05-03
Breaking changes
Remove support for deprecated LTV validation functionality. Call sites must be updated to use the AdES validation engine.
Several low-level API changes in
generic_cmsto allow refactoring the timestamp handling code.
extract_tst_data()was removed.
compute_signature_tst_digest()was removed.Several functions that previously took a digest to validate against have been changed to take a
(str) -> bytescallable.
Dependency changes
Bump
cryptographyto47.0.0.Relax upper bound on
pytest-covto<7.2.Relax upper bound on
certomancerto<0.15.Introduce
certifias a mandatory dependency for testing.
New features and enhancements
Validation
Properly support harvesting PoE from multiple signature/content timestamps in the same signature container.
For the purposes of validation status reporting: if there are multiple signature timestamps, accept any one that passes validation (this is appropriate since the main value of timestamps is evidentiary). At some point in the future, we may want to add a way to report on the status of all timestamps>
Add revinfo archival data to local knowledge.
Restructure algorithm policy handling. Algorithm policy errors will typically not bubble up outside the validation engine anymore, but will instead be reflected in the validation status.
Miscellaneous
Replace FreeSerif usage in tests with SourceSerif
Tweak
MediaBoxretrieval.
Bugs fixed
Fix
/APpositioning on field creation.Fix annot dict not being re-serialised on signing when split from form dictionary.
Improve error handling in
parse_pdf_date.Fix handling of PoE requirements in past validation data.
0.34.1
Release date: 2026-03-08
Bugs fixed
Address a packaging error with
testsdirectory in sdists.
0.34.0
Release date: 2026-03-05
Breaking changes
Drop support for Python 3.9
Dependency changes
Relax upper bound on
xsdatato<27.0.
New features and enhancements
Miscellaneous
Include tests in sdists again, and graft common testing tooling onto the sdists so they can be tested in a self-contained way.
Bugs fixed
Fix signed attribute enumeration in AdES report.
FieldMDP INCLUDE/EXCLUDE incorrectly locking fields with shared name prefix.
0.33.0
Release date: 2026-02-08
Dependency changes
Fix inconsistent
aiohttpversion bounds.Relax
uharfbuzzupper bound to<0.54.0.Bump
python-barcodeto==0.16.1.
New features and enhancements
Signing
Explicitly define a no-op stamping style
Miscellaneous
Integrate some actual signing hardware into CI processes.
Bugs fixed
Use embedded intermediate certificates when validating existing timestamps.
0.32.0
Release date: 2025-11-22
Dependency changes
Support Python 3.14
Relax
uharfbuzzupper bound to<0.51.0.
Warning
PyHanko currently does not test against free-threaded Python builds. Feel free to raise issues related to free-threaded Python in the discussion forum or on the issue tracker if you’re sure the problem is pyHanko-related, but there are currently no concrete plans to actively pursue support for this.
New features and enhancements
Signing
Support reading PKCS#12 data from memory.
Make PKCS#11
sign_kwargseasier to customise in subclasses.
Miscellaneous
Support basic text field filling.
Put in place scaffolding for content stream parsing.
0.31.0
Release date: 2025-09-12
Breaking changes
Some pieces of the configuration API were refactored or pushed fully into the CLI layer.
The old LTV validation functionality provided by
async_validate_pdf_ltv_signature()
has now been deprecated and may be removed in a future release.
0.30.0
Release date: 2025-08-23
Dependency changes
Bump
python-pkcs11to0.9.x.Introduce
signxml>=4.2.0into[etsi]dependency group.
New features and enhancements
Signing
Allow custom text and stamp border colours.
Validation
Allow slotting in a custom validation implementation (e.g. to support validating signatures that require cryptographic primitives that aren’t supported in-tree). This applies to certificate validation as well. See
SignatureValidator.Add support for validating against ETSI TS 119 612 trusted lists (as used in the EU’s eIDAS programme) and deriving qualification judgments from such lists for signatures and timestamps. This is an incubating feature; in particular it is not yet exposed in the CLI.
0.29.1
Release date: 2025-06-20
Dependency changes
Bump
python-pkcs11to0.8.0.Relax
aiohttpupper bound to allow3.12.xand make sure we test against the most recent version.
Bugs fixed
Correct buggy behaviour when reauthenticating with a security handler.
Fix registration of multiple extensions in encrypted files.
Tolerate key usage violations when the signer is a trust anchor.
Remove unnecessary 3.8 compatibility code.
Make it easier to customise PKCS#11 queries
0.29.0
Release date: 2025-05-27
Breaking changes
- The root
pyhankopackage is now a namespace package.
The
pyhanko.keysandpyhanko.stampmodules were turned into packages, exposing the same API in their respective__init__.py, so this change is source-compatible.The
__version__and__version_info__attributes are no longer exposed at the root package level, but have been moved intopyhanko.version(which was also turned into a subpackage).
- Drop dependency on
clickinpyhankodistribution, move CLI code intopyhanko-cliinstead.
The CLI code still installs as
pyhanko.cliin the package hierarchy.There are no code-level changes for CLI plugins other than the requirement to add a dependency on
pyhanko-cli. In principle, this allows “old” plugins to keep working without needing a re-release as long aspyhanko-cliis installed together withpyhanko.Make the dependency on
qrcodeoptional (in the new[qr]dependency group)Replace
defusedxmlwith a dependency onlxml, configured appropriately. This was done in anticipation of some future feature work that will require a dependency onlxmleither way.
0.28.0
Release date: 2025-05-24
Breaking changes
Drop support for Python 3.8
Dependency changes
Retool repository structure as
uvmulti-project workspace.Include
pyhanko-certvalidatoras subproject.Remove dev-only & testing dependencies from package metadata.
Bugs fixed
Fix error in SHA-3 detection when determining whether to include the ISO/TS 32001 extension metadata.
0.27.1
Release date: 2025-05-14
New features and enhancements
Reinstated support for decrypting files using public-key encryption where 3DES or RC2 are used as the envelope encryption algorithm. The new integration uses
pyca/cryptography’sdecrepitsubpackage instead ofoscrypto.
0.27.0
Release date: 2025-05-12
Dependency changes
Relax
uharfbuzzupper bound to<0.51.0.Constrain
clickto<8.2.0while we address breaking changes.Bump test dependencies.
New features and enhancements
Layout
Allow choosing whether to apply stamps in the page’s default coordinate system, or in the frame of reference that is active at the end of the page’s content stream. The former is now the default.
Bugs fixed
Fix handling of “plugin unavailable” error.
Clear
/NeedAppearanceswhen putting in a signature.
0.26.0
Release date: 2025-03-08
Breaking changes
Some outdated algos for encrypting the security handler seed in a public-key encrypted PDF were dropped to get rid of
oscryptoas a direct dependency ofpyhanko. It is still pulled in viapyhanko-certvalidator, but it is no longer used for any cryptographic operations (which is significant, because of compatibility issues on systems that no longer ship OpenSSL 1.1.1)
Dependency changes
Relax
uharfbuzzupper bound to<0.47.0.Make
defusedxmla regular dependency, remove[xmp]dependency group.Remove
[extra-pubkey-algs]dependency group (see breaking change list)
New features and enhancements
Expose
signature_mechanismparameter in PKCS#11 API.
0.25.3
Release date: 2024-11-17
Dependency changes
Workflow dependency bumps
Set
aiohttpupper bound to3.12Bump
pyhanko-certvalidatorto0.26.5Bump
certomancerto0.12.3
Note: these changes make pyHanko compatible with the (unreleased) API change in asn1crypto #230, which is nevertheless already being shipped in some distros.
0.25.2
Release date: 2024-11-11
Dependency changes
Bump minimal
cryptographyversion to43.0.3.Update
uharfbuzzupper bound to0.42.0.Add Python 3.13 to the package metadata & include it in CI.
Some test dependencies bumped.
Bugs fixed
Properly propagate
strict=Falsein post-signing instructions.
0.25.1
Release date: 2024-07-18
Bugs fixed
Align usage of SHAKE256 OIDs with Ed448 with RFC 8419
0.25.0
Release date: 2024-05-06
New features and enhancements
Encryption
Implement ISO/TS 32003 and ISO/TS 32004, to support AES-GCM streams and MAC authentication in encrypted PDF 2.0 documents, respectively. MACs are turned on by default when creating documents with PDF 2.0-style encryption.
0.24.0
Release date: 2024-04-27
Breaking changes
Setting & retrieving permission flags for encrypted files now comes with an ergonomic API that is much less error-prone. You no longer have to manually convert your permission bits to their signed integer representation. See
pyhanko.pdf_utils.crypt.permissions.
Dependency changes
Upgraded
xsdata(optional) to24.4.
Bugs fixed
Several issues with copying objects from encrypted documents (in particular, encrypted documents with signatures) have been fixed.
Tolerate unpadded empty ciphertext.
Improve error messages on malformed keys.
0.23.2
Release date: 2024-03-25
Dependency changes
Upgraded
certomancerdependency for tests to0.12.0.Upgraded
pytest-asynciotot0.23.6.
Bugs fixed
Fix handling of “OAEP preferred” flag when encrypting documents with a public key.
Fix endianness issue when reading & writing permissions in documents encrypted with a public key.
Tolerate AcroForm**s without a **Fields entry.
Increase resilience against issues with
oscrypto.
0.23.1
Release date: 2024-03-14
Bugs fixed
Fix a regression in the way PKCS#11 objects are loaded.
0.23.0
Release date: 2024-03-10
Breaking changes
The BeID signer implementation and CLI command was moved into a separate package; see pyhanko-beid-plugin. While this integration was so far preserved in the core tree for historical reasons, pyHanko has matured beyond this kind of vendor/country-specific code. Note that CLI invocations will continue to work unchanged as long as
pyhanko-beid-pluginis installed alongside pyHanko, thanks to Python’s package entry point mechanism.
0.22.0
Release date: 2024-03-07
Dependency changes
Relax upper bounds on
xsdataanduharfbuzz.
cryptography` to ``42.0.1Get rid of
pytest-runner
New features and enhancements
Signing
Relax processing of PKCS#11 options, setting better defaults so users have to write less config to select their key/certificate. (see PR #296)
CLI
Add
timestampcommand to CLI to add a document timestamp without performing any PAdES validation.
Bugs fixed
Gracefully handle lack of
/Typeentry in signature objects vailidation.
0.21.0
Release date: 2023-11-26
Dependency changes
Bumped the minimal supported Python version to 3.8 (dropping 3.7).
Bumped the lower bound on
qrcodeto7.3.1.Bumped
pyhanko-certvalidatorto0.26.x.Bumped the lower bound on
clickto8.1.3.Bumped the lower bound on
requeststo2.31.0.Bumped the lower bound on
pyyamlto6.0.Bumped the lower bound on
cryptographyto41.0.5.Bumped
aiohttpto3.9.x.Bumped
certomancer-csc-dummytest dependency to0.2.3.Introduced new dependency group
etsiwithxsdatafor features implementing functionality from AdES and related ETSI standards.
New features and enhancements
Signing
Add support for
/ContactInfo,/Prop_AuthTimeand/Prop_AuthType.
Validation
Experimental support for AdES validation reports (requires new
etsioptional deps)New API function for simulating PAdES-LTA validation at a time in the future; see
simulate_future_ades_lta_validation().Add support for asserting the nonrevoked status of a certificate chain.
CLI
Add
--resaveflag toaddfieldssubcommand.
Bugs fixed
Fixed an oversight in the serialisation of the
/ByteRangeentry in a signature that prevented large documents from being signed correctly.Various adjustments to the (still experimental) AdES validation API.
Various local documentation fixes.
PDF signatures that do not omit the
eContentfield in their encapsulated content info are now rejected as invalid.
Miscellaneous
Include PyPDF2 licence file in package metadata.
Cleaned up loading logic in
PdfFileReader. The most important impact of this change is that structural errors in the encryption dictionary will now cause exceptions to be thrown when decryption is attempted, not in the__init__function.
0.20.1
Release date: 2023-09-17
Dependency changes
Upgrade
pyhanko-certvalidatorto0.24.x
Miscellaneous
Tolerate missing
D:in date strings (see PR #296).Various minor documentation improvements.
Release workflow dependency bumps and minor improvements.
0.20.0
Release date: 2023-07-28
Dependency changes
Relax upper bound on
uharfbuzzto<0.38.0(allows more users to benefit from prebuilt wheels)Bump
python-barcodefrom0.14.0to0.15.1.Bump
pytest-asynciofrom0.21.0to0.21.1.Relax
pytest-covbound to allow4.1.x
Miscellaneous
Various minor documentation improvements.
Improved unit test coverage, especially for error handling.
0.19.0
Release date: 2023-06-18
Dependency changes
Bump
pyhanko-certvalidatorto0.23.0
certomancerupdated to0.11.0,certomancer-csc-dummyto0.2.2
Breaking changes
Minor reorganisation of the
EnvelopeKeyDecrypter. The change moves thecertproperty from an attribute to an abstract property, and adds a method to allow us to handle protocols based on key agreement in addition to key transport. Implementations need not implement both.Move
ignore_key_usageinto to newRecipientEncryptionPolicyclass.
New features and enhancements
Encryption
Support RSAES-OAEP for file encryption with the public-key security handler. This is not widely supported by PDF viewers in the wild.
Support some ECDH-based key exchange methods for file encryption with the public-key security handler. Concretely, pyHanko now supports the
dhSinglePass-stdDH-sha*kdffamily from RFC 5753, which is also implemented in Acrobat (for NIST curves). X25519 and X448 are also included.
CLI
Better UX for argument errors relating to visible signature creation.
Bugs fixed
Allow processing OCSP responses without
nextUpdate.Run non-cryptographic CLI commands in nonstrict mode.
Treat nulls the same as missing entries in dictionaries, as required by the standard.
Fix several default stamp style selection issues in CLI
0.18.1
Release date: 2023-04-29
Dependency changes
Remove dependency on
pytzwith fallback tobackports.zoneinfoBump
tzlocalversion to4.3.Do not rely on deprecated timezone API anymore in the tests. See PR #257.
0.18.0
Release date: 2023-04-26
Note
This is largely a maintenance release in the sense that it adds relatively little in the way of core features, but it nevertheless comes with some major reorganisation and work to address technical debt.
This release also marks pyHanko’s move to beta status. That doesn’t mean that
it’s feature-complete in every respect, but it does mean that we’ve now entered
a stabilisation phase in anticipation of the 1.0.0 release, so until then
the focus will be on fixing bugs and clearing up issues in the documentation (in
particular regarding the API contract). After the 1.0.0 release, pyHanko
will simply follow SemVer.
Breaking changes
Some changes have been made to the Signer class.
For all practical purposes, these are mostly relevant for custom
Signer implementations. Regular users should see
fairly little impact.
The arguments to
__init__have been made keyword-only.Several attributes have been turned into read-only properties:
This change was made to better reflect the way the properties were used internally, and made it easier to set expectations for the API: it doesn’t make sense to allow arbitrary modifications to these properties for all
Signerimplementations. The parameters to__init__have been extended to allow setting defaults more cleanly. Implementation-wise, the properties are backed by an underscored internal variable (e.g._signing_certforsigning_cert). Subclasses can of course still elect to make some of these read-only properties writable by declaring setters.
get_signature_mechanismwas renamed toget_signature_mechanism_for_digest()to make it more clear that it does more than just fetch the underlying value ofsignature_mechanism.
Concretely, this means that init logic of the form
class MySigner(Signer):
def __init__(
self,
signing_cert: x509.Certificate,
cert_registry: CertificateStore,
*args, **kwargs
):
self.signing_cert = signing_cert
self.cert_registry = cert_registry
self.signature_mechanism = signature_mechanism
super().__init__()
needs to be rewritten as
class MySigner(Signer):
def __init__(
self,
signing_cert: x509.Certificate,
cert_registry: CertificateStore,
*args, **kwargs
):
self._signing_cert = signing_cert
self._cert_registry = cert_registry
self._signature_mechanism = signature_mechanism
super().__init__()
or, alternatively, as
class MySigner(Signer):
def __init__(
self,
signing_cert: x509.Certificate,
cert_registry: CertificateStore,
*args, **kwargs
):
super().__init__(
signing_cert=signing_cert,
cert_registry=cert_registry,
signature_mechanism=signature_mechanism
)
Other than these, there have been some miscellaneous changes.
The CLI no longer allows signing files encrypted using public-key encryption targeted towards the signer’s certificate, because that feature didn’t make much sense in key management terms, was rarely used, and hard to integrate with the new plugin system.
APIs with
status_clsparameters have made certain args keyword-only for strict type checking purposes.Move
add_content_to_pagetoadd_to_page()to deal with a (conceptual) circular dependency between modules.
CertificateStoreis no longer reexported bypyhanko.sign.general.The
BEIDSignerno longer allows convenient access to the authentication certificate.Packaging-wise, underscores have been replaced with hyphens in optional dependency groups.
In
pyhanko_certvalidator,InvalidCertificateErroris no longer a subclass ofPathValidationError.
Finally, some internal refactoring took place as well:
The
cli.pymodule was refactored into a new subpackage (pyhanko.cli) and is now also tested systematically.CLI config classes have been refactored, some configuration was moved to the new
pyhanko.configpackage.Time tolerance config now passes around timedelta objects instead of second values.
The
qualify()function in the difference analysis has been split intoqualify()andqualify_transforming().
Organisational changes
Certificate and key loading was moved to a new
pyhanko.keysmodule, butpyhanko.sign.generalstill reexports the relevant functions for backwards compatibility. Concretely, the affected functions are
pyhanko.keys.load_cert_from_pemder(),
pyhanko.keys.load_certs_from_pemder(),
pyhanko.keys.load_certs_from_pemder_data(),
pyhanko.keys.load_private_key_from_pemder(),
pyhanko.keys.load_private_key_from_pemder_data().
Onboarded
mypyand flag pyHanko as a typed library by addingpy.typed.Package metadata and tooling settings have now been centralised to
pyproject.toml. Other configuration files likesetup.py,requirements.txtand most tool-specific config have been eliminated.The docstring-based documentation for
pyhanko_certvalidatorwas added to the API reference.Some non-autogenerated API reference documentation pages were consolidated to reduce the sprawl.
Heavily reworked the CI/CD pipeline. PyHanko releases are now published via GitHub Actions and signed with Sigstore. GPG signatures will continue to be provided for the time being.
Dependency changes
Bump
pyhanko-certvalidatorto0.22.0.Relax the upper bound on
uharfbuzzfor better Python 3.11 support
Bugs fixed
The AdES LTA validator now tolerates documents that don’t have a DSS (assuming that all the required information is otherwise present).
Ensure that the
trustedattribute onSignatureStatusis not set if the validation path is not actually available.Correct the typing on
validation_path.Fix several result presentation bugs in the AdES code.
Fix overeager sharing of
POEManagerobjects in AdES code.Correct algo policy handling in AdES-with-time validation.
Ensure that
container_refis also populated on past versions of the trailer dictionary.
New features and enhancements
Signing
The CLI now features plugins! All current
addsigsubcommands have been reimplemented to use the plugin interface. Other plugins will be auto-detected through package entry points.
Validation
Refine algorithm policy handling; put in place a subclass of
AlgorithmUsagePolicyspecifically for CMS validation; seeCMSAlgorithmUsagePolicy.Try to remember paths when validation fails.
Make certificates from local CMS context available during path building for past certificate validation (subject to PoE checks).
Move
docmdp_okup in the hierarchy toModificationInfo.
0.17.2
Release date: 2023-03-10
Note
This is a follow-up on yesterday’s bugfix release, addressing a number of similar issues.
Bugs fixed
Address another potential infinite loop in the comment processing logic.
Fix some (rather esoteric) correctness issues w.r.t. PDF whitespace.
0.17.1
Release date: 2023-03-09
Note
This is a maintenance release without significant functionality changes. It contains a bugfix, addresses some documentation issues and applies the Black formatter to the codebase.
Bugs fixed
Address a potential infinite loop in the PDF parsing logic. See PR #237.
0.17.0
Release date: 2023-01-31
Note
This is a bit of an odd release. It comes with relatively few functional changes or enhancements to existing features, but it has nevertheless been in the works for quite a long time.
In early 2022, I decided that the time was right to equip pyHanko with its own AdES validation engine, implementing the machinery specified by ETSI EN 319 102-1. I knew ahead of time that this would not be an easy task:
PyHanko’s own validation code was put together in a fairly ad-hoc manner starting from the provisions in the CMS specification, so some refactoring would be necessary.
pyhanko-certvalidatoralso was never designed to be anything more than an RFC 5280 validation engine, and retrofitting the fine-tuning required by the AdES spec definitely wasn’t easy.
Initially, I estimated that this effort would take a few months tops. Yet here
we are, approximately one year down the road: pyhanko.sign.validation.ades.
Truth be told, the implementation isn’t yet ready for prime time, but it is in
a state where it’s at least useful for experimentation purposes, and can be
iterated on.
Also, given the volume of subtle changes and far-reaching refactoring in the
internals of both the pyhanko and pyhanko-certvalidator packages,
continually rebasing the feature/ades-validation feature branch turned
into a chore quite quickly.
So, if you’re keen to start playing around with AdES validation: please do so, and let me know what you think. If standards-based validation is not something you care about, feel free to disregard everything I wrote above, it almost certainly won’t affect any of your code.
My plan is to incrementally build upon and polish the code in
pyhanko.sign.validation.ades, and eventually deprecate the current
ad-hoc LTV validation logic in
pyhanko.sign.validation.ltv.async_validate_pdf_ltv_signature().
That’s still a ways off from now, though.
Dependency updates
pyhanko-certvalidatorupdated to0.20.0
Breaking changes
There are various changes in the validation internals that are not backwards compatible, but all of those concern internal APIs.
There are some noteworthy changes to the
pyhanko-certvalidatorAPI. Those are documented in the change log. Most of these do not affect basic usage.
New features and enhancements
Validation
Experimental AdES validation engine
pyhanko.sign.validation.ades.In the status API, make a more meaningful distinction between
validandintact, and document that distinction.
0.16.0
Release date: 2022-12-21
Dependency updates
pyhanko-certvalidatorupdated to0.19.8
Breaking changes
This release includes breaking changes to the difference analysis engine. Unless you’re implementing your own difference analysis policies, this change should break your API usage.
New features and enhancements
Signing
Add support for Prop_Build metadata in signatures. See PR #192
Validation
Improvements to the difference analysis engine that allow more nuance to be expressed in the rule system.
Bugs fixed
Tolerate an indirect Extensions and MarkInfo dictionary in difference analysis. See PR #177.
Gracefully handle unreadable/undecodable producer strings.
0.15.1
Release date: 2022-10-27
Note
This release adds Python 3.11 to the list of supported Python versions.
Dependency updates
pyhanko-certvalidatorupdated to0.19.6
certomancerupdated to0.9.1
Bugs fixed
Be more tolerant towards deviations from DER restrictions in signed attributes when validating signatures.
0.15.0
Release date: 2022-10-11
Note
Other than a few bug fixes, the highlight of this release is the addition of support for two very recently published PDF extension standards, ISO/TS 32001 and ISO/TS 32002.
Bugs fixed
Fix metadata handling in encrypted documents see issue #160.
Make sure XMP stream dictionaries contain the required typing entries.
Respect
visible_sig_settingson field autocreation.Fix a division by zero corner case in the stamp layout code; see issue #170.
New features and enhancements
Signing
Add support for the new PDF extensions defined by ISO/TS 32001 and ISO/TS 32002; see PR #169.
SHA-3 support
EdDSA support for both the PKCS#11 signer and the in-memory signer
Auto-register developer extensions in the file
Make it easier to extract keys from
bytesobjects.
Validation
Add support for validating EdDSA signatures (as defined in ISO/TS 32002)
0.14.0
Release date: 2022-09-17
Note
This release contains a mixture of minor and major changes. Of particular note is the addition of automated metadata management support, including XMP metadata. This change affects almost every PDF write operation in the background. While pyHanko has very good test coverage, some instability and regressions may ensue. Bug reports are obviously welcome.
Breaking changes
The breaking changes in this release are all relatively minor.
Chances are that your code isn’t affected at all, other than perhaps by
the change to
PreparedByteRangeDigest.
md_algorithmattribute removed fromPreparedByteRangeDigestsince it wasn’t necessary for further processing.Low-level change in
raw_getfor PDF container object types (ArrayObjectandDictionaryObject): thedecryptparameter is no longer a boolean, but a tri-state enum value of typeEncryptedObjAccess.Developer extension management API moved into
pyhanko.pdf_utils.extensions.
get_courier()convenience function moved intopyhanko.pdf_utils.font.basicand now takes a mandatory writer argument.The
token_labelattribute was removed fromPKCS11SignatureConfig, but will still be parsed (with a deprecation warning).The
prompt_pinattribute inPKCS11SignatureConfigwas changed from a bool to an enum. SeePKCS11PinEntryMode.
Dependency updates
pytest-aiohttpupdated to1.0.4
certomancerupdated to0.9.0
certomancer-csc-dummyupdated to0.2.1Relax bounds on
uharfbuzzto allow everything up to the current version (i.e.0.30.0) as well.New optional dependency group
xmp, which for now only containsdefusedxml
Bugs fixed
Allow certificates with no
CNin the certificate subject.The extension dictionary handling logic can now deal with encrypted documents without actually decrypting the document contents.
Fix processing error when passing empty strings to
uharfbuzz; see issue #132.Use proper PDF text string serialisation routine in simple font handler, to ensure everything is escaped correctly.
Ensure that
output_versionis set to at least the input version in incrementally updated files.
New features and enhancements
Signing
Drop the requirement for
signing_certto be set from the start of the signing process in an interrupted signing workflow. This has come up on several occasions in the past, since it’s necessary in remote signing scenarios where the certificate is generated or provided on-demand when submitting the document digest to the signing service. See pull #141 for details.Add convenience API to set the
/TUentry on a signature field; seereadable_field_name.Allow greater control over the initialisation of document timestamp fields.
New class hierarchy for (un)signed attribute provisioning; see
SignedAttributeProviderSpecandUnsignedAttributeProviderSpec.Allow greater control over annotation flags for visible signatures. This is implemented using
VisibleSigSettings. See discussion #150.Factor out and improve PKCS#11 token finding; see
TokenCriteriaand issue #149.Factor out and improve PKCS#11 mechanism selection, allowing more raw modes.
Change pin entry settings for PKCS#11 to be more granular, in order to also allow
PROTECTED_AUTH; see issue #133.Allow the PKCS#11 PIN to be sourced from an environment variable when pyHanko is invoked through the CLI and no PIN is provided in the configuration. PyHanko will now first check the
PYHANKO_PKCS11_PINvariable before prompting for a PIN. This also works when prompting for PIN entry is disabled altogether.
Note
The PKCS#11 code is now also tested in CI, using SoftHSMv2.
Validation
Allow validation time overrides in the CLI. Passing in the special value
claimedtells pyHanko to take the stated signing time in the file at face value. See issue #130.
Encryption
Also return permissions on owner access to allow for easier inspection.
Better version enforcement for security handlers.
Layout
Allow metrics to be specified for simple fonts.
Provide metrics for default Courier font.
Experimental option that allows graphics to be embedded in the central area of the QR code; see
qr_inner_content.
Miscellaneous
Basic XMP metadata support with optional
xmpdependency group.Automated metadata management (document info dictionary, XMP metadata).
Refactor some low-level digesting and CMS validation code.
Make the CLI print a warning when the key passphrase is left empty.
Tweak configuration management utilities to better cope with fallback logic for deprecated configuration parameters.
Move all cross-reference writing logic into
pyhanko.pdf_utils.xref.Improve error classes and error reporting in the CLI so that errors in non-verbose mode still provide a little more info.
0.13.2
Release date: 2022-07-02
Note
This is a patch release to address some dependency issues and bugs.
Dependency updates
python-barcodeupdated and pinned to0.14.0.
Bugs fixed
Fix lack of newline after XRef stream header.
Do not write DigestMethod in signature reference dictionaries (deprecated/nonfunctional entry).
Make
pyhanko.pdf_utils.writer.copy_into_new_writer()more flexible by allowing caller-specified keyword arguments for the writer object.Refine settings for invisible signature fields (see
pyhanko.sign.fields.InvisSigSettings).Correctly read objects from object streams in encrypted documents.
0.13.1
Release date: 2022-05-01
Note
This is a patch release to update fontTools and uharfbuzz to address
a conflict between the latest fontTools and older uharfbuzz versions.
Dependency updates
fontToolsupdated to4.33.3
uharfbuzzupdated to0.25.0
0.13.0
Release date: 2022-04-25
Note
Like the previous two releases, this is largely a maintenance release.
Dependency updates
asn1cryptoupdated to1.5.1
pyhanko-certvalidatorupdated to0.19.5
certomancerupdated to0.8.2Depend on
certomancer-csc-dummyfor tests; get rid ofpython-paetest dependency.
Bugs fixed
Various parsing robustness improvements.
Be consistent with security handler version bounds.
Improve coverage of encryption code.
Ensure owner password gets prioritised in the legacy security handler.
New features and enhancements
Miscellaneous
Replaced some
ValueErrorusages withPdfErrorImprovements to error handling in strict mode.
Make CLI stack traces less noisy by default.
Encryption
Refactor internal
cryptmodule into package.Add support for serialising credentials.
Cleaner credential inheritance for incremental writers.
Signing
Allow post-signing actions on encrypted files with serialised credentials.
Improve
--use-pades-ltaergonomics in CLI.Add
--no-passparameter topemderCLI.
Validation
Preparatory scaffolding for AdES status reporting.
Provide some tolerance against malformed ACs.
Increase robustness against invalid DNs.
0.12.1
Release date: 2022-02-26
Dependency updates
uharfbuzzupdated to0.19.0
pyhanko-certvalidatorupdated to0.19.4
certomancerupdated to0.8.1
Bugs fixed
Fix typing issue in DSS reading logic (see issue #81)
0.12.0
Release date: 2022-01-26
Note
This is largely a maintenance release, and contains no new high-level features or public API changes. As such, upgrading is strongly recommended.
The most significant change is the (rather minimalistic) support for hybrid reference files. Since working with hybrid reference files means dealing with potential ambiguity (which is dangerous when dealing with signatures), creation and validation of signatures in hybrid reference documents is only enabled in nonstrict mode. Hybrid reference files are relatively rare these days, but the internals need to be able to cope with them either way, in order to be able to update such files safely.
New features and enhancements
Miscellaneous
Significant refactor of cross-reference parsing internals. This doesn’t affect any public API entrypoints, but read the reference documentation for
pyhanko.pdf_utils.xrefif you happen to have code that directly relies on that internal logic.Minimal support for hybrid reference files.
Add
strictflag toIncrementalPdfFileWriter.Expose
--no-strict-syntaxCLI flag in theaddsigsubcommand.
Bugs fixed
Ensure that signature appearance bounding boxes are rounded to a reasonable precision. Failure to do so caused issues with some viewers.
To be consistent with the purpose of the strictness flag, non-essential xref consistency checking is now only enabled when running in strict mode (which is the default).
The hybrid reference support indirectly fixes some potential silent file corruption issues that could arise when working on particularly ill-behaved hybrid reference files.
0.11.0
Release date: 2021-12-23
Dependency changes
Update
pyhanko-certvalidatorto0.19.2Bump
fontToolsto4.28.2Update
certomancertest dependency to0.7.1
Breaking changes
Due to import order issues resulting from refactoring of the validation code, some classes and class hierarchies in the higher-level API had to be moved. The affected classes are listed below, with links to their respective new locations in the API reference.
The low-level function validate_sig_integrity() was also
moved.
New features and enhancements
Signing
Support embedding attribute certificates into CMS signatures, either in the
certificatesfield or using the CAdESsigner-attrs-v2attribute.More explicit errors on unfulfilled text parameters
Better use of
asynciowhen collecting validation information for timestampsInternally disambiguate PAdES and CAdES for the purpose of attribute handling.
Validation
Refactor
diff_analysismodule into sub-packageRefactor
validationmodule into sub-package (together with portions ofpyhanko.sign.general); see Breaking changes.Make extracted certificate information more easily accessible.
Integrated attribute certificate validation (requires a separate validation context with trust roots for attribute authorities)
Report on signer attributes as supplied by the CAdES
signer-attrs-v2attribute.
Miscellaneous
Various parsing and error handling improvements to xref processing, object streams, and object header handling.
Use
NotImplementedErrorfor unimplemented stream filters instead of less-appropriate exceptionsAlways drop GPOS/GDEF/GSUB when subsetting OpenType and TrueType fonts
Initial support for string-keyed CFF fonts as CIDFonts (subsetting is still inefficient)
copy_into_new_writer()is now smarter about how it deals with the/ProducerlineFix a typo in the ASN.1 definition of
signature-policy-storeVarious, largely aesthetic, cleanup & docstring fixes in internal APIs
Bugs fixed
Fix a critical bug in content timestamp generation causing the wrong message imprint to be sent to the timestamping service. The bug only affected the signed
content-time-stampattribute from CAdES, not the (much more widely used)signature-time-stampattribute. The former timestamps the content (and is part of the signed data), while the latter timestamps the signature (and is therefore not part of the signed data).Fix a bug causing an empty unsigned attribute sequence to be written if there were no unsigned attributes. This is not allowed (although many validators accept it), and was a regression introduced in
0.9.0.Ensure non-PDF CAdES signatures always have
signingTimeset.Fix and improve timestamp summary reporting
Corrected TrueType subtype handling
Properly set
ts_validation_pathsGracefully deal with unsupported certificate types in CMS
Ensure attribute inspection internals can deal with
SignerInfowithoutsignedAttrs.
0.10.0
Release date: 2021-11-28
Dependency changes
Update
pyhanko-certvalidatorto0.18.0Update
aiohttpto3.8.0(optional dependency)Introduce
python-pae==0.1.0(tests)
New features and enhancements
Signing
There’s a new
Signerimplementation that allows pyHanko to be used with remote signing services that implement the Cloud Signature Consortium API. Since auth handling differs from vendor to vendor, using this feature requires still the caller to supply an authentication handler implementation; seepyhanko.sign.signers.csc_signerfor more information. This feature is currently incubating.
Validation
Add CLI option to skip diff analysis.
Add CLI flag to disable strict syntax checks.
Use chunked digests while validating.
Improved difference analysis logging.
Miscellaneous
Better handling of nonexistent objects: clearer errors in strict mode, better fallback behaviour in nonstrict mode. This applies to both regular object dereferencing and xref history analysis.
Added many new tests for various edge cases, mainly in validation code.
Added
Python :: 3andPython :: 3.10classifiers to distribution.
Bugs fixed
Fix bug in output handler in timestamp updater that caused empty output in some configurations.
Fix a config parsing error when no stamp styles are defined in the configuration file.
0.9.0
Release date: 2021-10-31
Dependency changes
Update
pyhanko-certvalidatorto0.17.3Update
fontToolsto4.27.1Update
certomancerto0.6.0(tests)Introduce
pytest-aiohttp~=0.3.0andaiohttp>=3.7.4(tests)
API-breaking changes
This is a pretty big release, with a number of far-reaching changes in the
lower levels of the API that may cause breakage.
Much of pyHanko’s internal logic has been refactored to prefer asynchronous I/O
wherever possible (pyhanko-certvalidator was also refactored accordingly).
Some compromises were made to allow non-async-aware code to continue working as-is.
If you’d like a quick overview of how you can take advantage of the new asynchronous library functions, take a look at this section in the signing docs.
Here’s an overview of low-level functionality that changed:
CMS signing logic was refactored and made asynchronous (only relevant if you implemented your own custom signers)
Time stamp client API was refactored and made asynchronous (only relevant if you implemented your own time stamping clients)
The interrupted signing workflow now involves more asyncio as well.
perform_presign_validation()was made asynchronous.
prepare_tbs_document(): thebytes_reservedparameter is mandatory now.
post_signature_processing()was made asynchronous.
collect_validation_info()was made asynchronous
Other functions have been deprecated in favour of asynchronous equivalents;
such deprecations are documented in the API reference.
The section on extending Signer
has also been updated.
Warning
Even though we have pretty good test coverage, due to the volume of changes, some instability may ensue. Please do not hesitate to report bugs on the issue tracker!
New features and enhancements
Signing
Async-first signing API
Relax
token-labelrequirements in PKCS#11 config, allowingslot-noas an alternativeAllow selecting keys and certificates by ID in the PKCS#11 signer
Allow the signer’s certificate to be sourced from a file in the PKCS#11 signer
Allow BeID module path to be specified in config
Tweak cert querying logic in PKCS#11 signer
Add support for raw ECDSA to the PKCS#11 signer
Basic DSA support (for completeness w.r.t. ISO 32000)
Choose a default message digest more cleverly, based on the signing algorithm and key size
Fail loudly when trying to add a certifying signature to an already-signed document using the high-level signing API
Provide a flag to skip embedding root certificates
Validation
Async-first validation API
Use non-zero exit code on failed CLI validation
Miscellaneous
Minor reorganisation of
config.pyfunctionsMove PKCS#11 pin prompt logic to
cli.pyImprove font embedding efficiency (better stream management)
Ensure idempotence of object stream flushing
Improve PKCS#11 signer logging
Make
stream_xrefs=Falseby default incopy_into_new_writer()Removed a piece of fallback logic for
md_algorithmthat relied on obsolete parts of the standardFixed a number of issues related to unexpected cycles in PDF structures
Bugs fixed
Treat ASCII form feed (
\f) as PDF whitespaceFix a corner case with null incremental updates
Fix some font compatibility issues (relax assumptions about the presence of certain tables/entries)
Be more tolerant when parsing name objects
Correct some issues related to DSS update validation
Correct
pdf_date()output for negative UTC offsets
0.8.0
Release date: 2021-08-23
Dependency changes
Update
pyhanko-certvalidatorto0.16.0.
API-breaking changes
Some fields and method names in the config API misspelled pkcs11` as ``pcks11. This has been
corrected in this release. This is unlikely to cause issues for library users (since the config API
is primarily used by the CLI code), but it’s a breaking change all the same.
If you do have code that relies on the config API, simply substituting s/pcks/pkcs/g should fix
things.
New features and enhancements
Signing
Make certificate fetching in the PKCS#11 signer more flexible.
Allow passing in the signer’s certificate from outside the token.
Improve certificate registry initialisation.
Give more control over updating the DSS in complex signature workflows. By default, pyHanko now tries to update the DSS in the revision that adds a document timestamp, after the signature (if applicable). In the absence of a timestamp, the old behaviour persists.
Added a flag to (attempt to) produce CMS signature containers without any padding.
Use
signing-certificate-v2instead ofsigning-certificatewhen producing signatures.Default to empty appearance streams for empty signature fields.
Much like the
pkcs11-setupsconfig entry, there are nowpemder-setupsandpkcs12-setupsat the top level of pyHanko’s config file. You can use those to store arguments for thepemderandpkcs12subcommands of pyHanko’saddsigcommand, together with passphrases for non-interactive use. See Named setups for on-disk key material.
Validation
Enforce the end-entity cert constraint imposed by the
signing-certificateorsigning-certificate-v2attribute (if present).Improve issuer-serial matching logic.
Improve CMS attribute lookup routines.
Encryption
Add a flag to suppress creating “legacy compatibility” entries in the encryption dictionary if they aren’t actually required or meaningful (for now, this only applies to
/Length).
Miscellaneous
Lazily load the version entry in the catalog.
Minor internal I/O handling improvements.
Allow constructing an
IncrementalPdfFileWriterfrom aPdfFileReaderobject.Expose common API to modify (most) trailer entries.
Automatically recurse into all configurable fields when processing configuration data.
Replace some certificate storage/indexing classes by references to their corresponding classes in
pyhanko-certvalidator.
Bugs fixed
Add
/NeedAppearancesin the AcroForm dictionary to the whitelist for incremental update analysis.Fixed several bugs related to difference analysis on encrypted files.
Improve behaviour of dev extensions in difference analysis.
Fix encoding issues with
SignedDigestAlgorithm, in particular ensuring that the signature mechanism encodes the relevant digest when using ECDSA.Process passfile contents more robustly in the CLI.
Correct timestamp revinfo fetching (by ensuring that a dummy response is present)
0.7.0
Release date: 2021-07-25
Dependency changes
Warning
If you used OTF/TTF fonts with pyHanko prior to the 0.7.0 release, you’ll need HarfBuzz
going forward. Install pyHanko with the [opentype] optional dependency group to grab
everything you need.
Update
pyhanko-certvalidatorto0.15.3TrueType/OpenType support moved to new optional dependency group labelled
[opentype].Dependency on
fontToolsmoved from core dependencies to[opentype]group.We now use HarfBuzz (
uharfbuzz==0.16.1) for text shaping with OTF/TTF fonts.
API-breaking changes
Warning
If you use any of pyHanko’s lower-level APIs, review this section carefully before updating.
Signing code refactor
This release includes a refactor of the pyhanko.sign.signers module into a
package with several submodules. The original API exposed by this
module is reexported in full at the package level, so existing code using pyHanko’s publicly
documented signing APIs should continue to work without modification.
There is one notable exception: as part of this refactor, the low-level
PdfCMSEmbedder protocol was tweaked slightly, to support
the new interrupted signing workflow (see below). The required changes to existing code should be
minimal; have a look at the relevant section in the library
documentation for a concrete description of the changes, and an updated usage example.
In addition, if you extended the PdfSigner
class, then you’ll have to adapt to the new internal signing workflow as well. This may be
tricky due to the fact that the separation of concerns between different steps in the signing
process is now enforced more strictly.
I’m not aware of use cases requiring PdfSigner
to be extended, but if you’re having trouble migrating your custom subclass to the new API
structure, feel free to open an issue.
Merely having subclassed Signer shouldn’t require
you to change anything.
Fonts
The low-level font loading API has been refactored to make font resource handling less painful, to provide smoother HarfBuzz integration and to expose more OpenType tweaks in the API.
To this end, the old pyhanko.pdf_utils.font module was turned into a package containing three
modules: api, basic and
opentype. The api
module contains the definitions for the general FontEngine and FontEngineFactory classes,
together with some other general plumbing logic.
The basic module provides a minimalist implementation with a
(non-embedded) monospaced font.
If you need TrueType/OpenType support, you’ll need the opentype
module together with the optional dependencies in the [opentype] dependency group (currently
fontTools and uharfbuzz, see above).
Take a look at the section for pyhanko.pdf_utils.font in
the API reference documentation for further details.
For the time being, there are no plans to support embedding Type1 fonts, or to offer support for Type3 fonts at all.
Miscellaneous
The
content_streamparameter was removed fromimport_page_as_xobject(). Content streams are now merged automatically, since treating a page content stream array non-atomically is a bad idea.
PdfSigneris no longer a subclass ofPdfTimeStamper.
New features and enhancements
Signing
Interrupted signing workflow: segmented signing workflow that can be interrupted partway through and resumed later (possibly in a different process or on a different machine). Useful for dealing with signing processes that rely on user interaction and/or remote signing services.
Generic data signing support: construct CMS
signedDataobjects for arbitrary data (not necessarily for use in PDF signature fields).Experimental API for signing individual embedded files (nonstandard).
PKCS#11 settings can now be set in the configuration file.
Validation
Add support for validating CMS
signedDatastructures against arbitrary payloads (see also: Generic data signing)Streamline CMS timestamp validation.
Support reporting on (CAdES) content timestamps in addition to signature timestamps.
Allow signer certificates to be identified by the
subjectKeyIdentifierextension.
Encryption
Support granular crypt filters for embedded files
Add convenient API to encrypt and wrap a PDF document as a binary blob. The resulting file will open as usual in a viewer that supports PDF collections; a fallback page with alternative instructions is shown otherwise.
Miscellaneous
Complete overhaul of appearance generation & layout system. Most of these changes are internal, except for some font loading mechanics (see above). All use of OpenType / TrueType fonts now requires the
[opentype]optional dependency group. New features:
Use HarfBuzz for shaping (incl. complex scripts)
Support TrueType fonts and OpenType fonts without a CFF table.
Support vertical writing (among other OpenType features).
Use ActualText marked content in addition to ToUnicode.
Introduce simple box layout & alignment rules, and apply them uniformly across all layout decisions where possible. See
pyhanko.stampandpyhanko.pdf_utils.layoutfor API documentation.Refactored stamp style dataclass hierarchy. This should not affect existing code.
Allow externally generated PDF content to be used as a stamp appearance.
Utility API for embedding files into PDF documents.
Added support for PDF developer extension declarations.
Bugs fixed
Signing
Declare ESIC extension when producing a PAdES signature on a PDF 1.x file.
Validation
Fix handling of orphaned objects in diff analysis.
Tighten up tolerances for (visible) signature field creation.
Fix typo in
BaseFieldModificationRuleDeal with some VRI-related corner cases in the DSS diffing logic.
Encryption
Improve identity crypt filter behaviour when applied to text strings.
Correct handling of non-default public-key crypt filters.
Miscellaneous
Promote stream manipulation methods to base writer.
Correct some edge cases w.r.t. PDF content import
Use floats for MediaBox.
Handle escapes in PDF name objects.
Correct ToUnicode CMap formatting.
Do not close over GSUB when computing font subsets.
Fix
output_versionhandling oversight.Misc. export list & type annotation corrections.
0.6.1
Release date: 2021-05-22
Dependency changes
Update
pyhanko-certvalidatorto0.15.2Replace constraint on
certomancerandpyhanko-certvalidatorby soft minor version constraint (~=)Set version bound for
freezegun
Bugs fixed
Add
/Qand/DAkeys to the whitelist for incremental update analysis on form fields.
0.6.0
Release date: 2021-05-15
Dependency changes
Warning
pyHanko’s 0.6.0 release includes quite a few changes to dependencies, some of which may
break compatibility with existing code. Review this section carefully before updating.
The pyhanko-certvalidator dependency was updated to 0.15.1.
This update adds support for name constraints, RSASSA-PSS and EdDSA for the purposes of X.509 path
validation, OCSP checking and CRL validation.
Warning
Since pyhanko-certvalidator has considerably diverged from “mainline” certvalidator,
the Python package containing its modules was also renamed from certvalidator to
pyhanko_certvalidator, to avoid potential namespace conflicts down the line. You should
update your code to reflect this change.
Concretely,
from certvalidator import ValidationContext
turns into
from pyhanko_certvalidator import ValidationContext
in the new release.
There were several changes to dependencies with native binary components:
The Pillow dependency has been relaxed to
>=7.2.0, and is now optional. The same goes forpython-barcode. Image & 1D barcode support now needs to be installed explicitly using the[image-support]installation parameter.PKCS#11 support has also been made optional, and can be added using the
[pkcs11]installation parameter.
The test suite now makes use of Certomancer.
This also removed the dependency on ocspbuilder.
New features and enhancements
Signing
Make preferred hash inference more robust.
Populate
/APwhen creating an empty visible signature field (necessary in PDF 2.0)
Validation
Timestamp and DSS handling tweaks:
Preserve OCSP resps / CRLs from validation kwargs when reading the DSS.
Gracefully process revisions that don’t have a DSS.
When creating document timestamps, the
validation_contextparameter is now optional.Enforce
certvalidator’sweak_hash_algoswhen validating PDF signatures as well. Previously, this setting only applied to certificate validation. By default, MD5 and SHA-1 are considered weak (for digital signing purposes).Expose
DocTimeStamp/Sigdistinction in a more user-friendly manner.
The
sig_object_typeproperty onEmbeddedPdfSignaturenow returns the signature’s type as a PDF name object.
PdfFileReadernow has two extra convenience properties namedembedded_regular_signaturesandembedded_timestamp_signatures, that return a list of all regular signatures and document timestamps, respectively.
Encryption
Refactor internal APIs in pyHanko’s security handler implementation to make them easier to extend. Note that while anyone is free to register their own crypt filters for whatever purpose, pyHanko’s security handler is still considered internal API, so behaviour is subject to change between minor version upgrades (even after
1.0.0).
Miscellaneous
Broaden the scope of
--soft-revocation-check.Corrected a typo in the signature of
validate_sig_integrity.Less opaque error message on missing PKCS#11 key handle.
Ad-hoc hash selection now relies on
pyca/cryptographyrather thanhashlib.
Bugs fixed
Correct handling of DocMDP permissions in approval signatures.
Refactor & correct handling of SigFlags when signing prepared form fields in unsigned files.
Fixed issue with trailing whitespace and/or
NULbytes in array literals.Corrected the export lists of various modules.
0.5.1
Release date: 2021-03-24
Bugs fixed
Fixed a packaging blunder that caused an import error on fresh installs.
0.5.0
Release date: 2021-03-22
Dependency changes
Update pyhanko-certvalidator dependency to 0.13.0.
Dependency on cryptography is now mandatory, and oscrypto has been marked optional.
This is because we now use the cryptography library for all signing and encryption operations,
but some cryptographic algorithms listed in the PDF standard are not available in cryptography,
so we rely on oscrypto for those. This is only relevant for the decryption of files encrypted
with a public-key security handler that uses DES, triple DES or RC2 to encrypt the key seed.
In the public API, we exclusively work with asn1crypto representations of ASN.1 objects, to
remain as backend-independent as possible.
Note: While oscrypto is listed as optional in pyHanko’s dependency list, it is still
required in practice, since pyhanko-certvalidator depends on it.
New features and enhancements
Encryption
Enforce
keyEnciphermentkey extension by default when using public-key encryptionShow a warning when signing a document using public-key encryption through the CLI. We currently don’t support using separate encryption credentials in the CLI, and using the same key pair for decryption and signing is bad practice.
Several minor CLI updates.
Signing
Allow customisation of key usage requirements in signer & validator, also in the CLI.
Actively preserve document timestamp chain in new PAdES-LTA signatures.
Support setups where fields and annotations are separate (i.e. unmerged).
Set the
lockbit in the annotation flags by default.Tolerate signing fields that don’t have any annotation associated with them.
Broader support for PAdES / CAdES signed attributes.
Validation
Support validating PKCS #7 signatures that don’t use
signedAttrs. Nowadays, those are rare in the wild, but there’s at least one common commercial PDF library that outputs such signatures by default (vendor name redacted to protect the guilty).
- Timestamp-related fixes:
Improve signature vs. document timestamp handling in the validation CLI.
Improve & test handling of malformed signature dictionaries in PDF files.
Align document timestamp updating logic with validation logic.
Correct key usage check for time stamp validation.
Allow customisation of key usage requirements in signer & validator, also in the CLI.
Allow LTA update function to be used to start the timestamp chain as well as continue it.
Tolerate indirect references in signature reference dictionaries.
Improve some potential ambiguities in the PAdES-LT and PAdES-LTA validation logic.
- Revocation info handling changes:
Support “retroactive” mode for revocation info (i.e. treat revocation info as valid in the past).
Added functionality to append current revocation information to existing signatures.
Related CLI updates.
Miscellaneous
Some key material loading functions were cleaned up a little to make them easier to use.
I/O tweaks: use chunked writes with a fixed buffer when copying data for an incremental update
Warn when revocation info is embedded with an offline validation context.
Improve SV validation reporting.
Bugs fixed
Fix issue with
/Certsnot being properly dereferenced in the DSS (#4).Fix loss of precision on
FloatObjectserialisation (#5).Add missing dunders to
BooleanObject.Do not use
.dump()withforce=Truein validation.Corrected digest algorithm selection in timestamp validation.
Correct handling of writes with empty user password.
Do not automatically add xref streams to the object cache. This avoids a class of bugs with some kinds of updates to files with broken xref streams.
Due to a typo, the
/Annotsarray of a page would not get updated correctly if it was an indirect object. This has been corrected.
0.4.0
Release date: 2021-02-14
New features and enhancements
Encryption
Expose permission flags outside security handler
Make file encryption key straightforward to grab
Signing
Mildly refactor PdfSignedData for non-signing uses
- Make DSS API more flexible
Allow direct input of cert/ocsp/CRL objects as opposed to only certvalidator output
Allow input to not be associated with any concrete VRI.
- Greatly improved PKCS#11 support
Added support for RSASSA-PSS and ECDSA.
Added tests for RSA functionality using SoftHSMv2.
Added a command to the CLI for generic PKCS#11.
Note: Tests don’t run in CI, and ECDSA is not included in the test suite yet (SoftHSMv2 doesn’t seem to expose all the necessary mechanisms).
Factor out unsigned_attrs in signer, added a digest_algorithm parameter to signed_attrs.
Allow signing with any BasePdfFileWriter (in particular, this allows creating signatures in the initial revision of a PDF file)
Add CMSAlgorithmProtection attribute when possible * Note: Not added to PAdES signatures for the time being.
Improved support for deep fields in the form hierarchy (arguably orthogonal to the standard, but it doesn’t hurt to be flexible)
Validation
- Path handling improvements:
Paths in the structure tree are also simplified.
Paths can be resolved relative to objects in a file.
- Limited support for tagged PDF in the validator.
Existing form fields can be filled in without tripping up the modification analysis module.
Adding new form fields to the structure tree after signing is not allowed for the time being.
- Internal refactoring in CMS validation logic:
Isolate cryptographic integrity validation from trust validation
Rename externally_invalid API parameter to encap_data_invalid
Validate CMSAlgorithmProtection when present.
Improved support for deep fields in the form hierarchy (arguably orthogonal to the standard, but it doesn’t hurt to be flexible).
Added
Miscellaneous
Export copy_into_new_writer.
Transparently handle non-seekable output streams in the signer.
Remove unused __iadd__ implementation from VRI class.
Clean up some corner cases in container_ref handling.
Refactored SignatureFormField initialisation (internal API).
Bugs fixed
Deal with some XRef processing edge cases.
Make signed_revision on embedded signatures more robust.
Fix an issue where DocTimeStamp additions would trigger /All-type field locks.
Fix some issues with modification_level handling in validation status reports.
Fix a few logging calls.
Fix some minor issues with signing API input validation logic.
0.3.0
Release date: 2021-01-26
New features and enhancements
Encryption
Reworked internal crypto API.
Added support for PDF 2.0 encryption.
Added support for public key encryption.
Got rid of the homegrown RC4 class (not that it matters all to much, RC4 isn’t secure anyhow); all cryptographic operations in crypt.py are now delegated to oscrypto.
Signing
Encrypted files can now be signed from the CLI.
With the optional cryptography dependency, pyHanko can now create RSASSA-PSS signatures.
Factored out a low-level PdfCMSEmbedder API to cater to remote signing needs.
Miscellaneous
The document ID can now be accessed more conveniently.
The version number is now single-sourced in version.py.
Initialising the page tree in a PdfFileWriter is now optional.
Added a convenience function for copying files.
Validation
With the optional cryptography dependency, pyHanko can now validate RSASSA-PSS signatures.
Difference analysis checker was upgraded with capabilities to handle multiply referenced objects in a more straightforward way. This required API changes, and it comes at a significant performance cost, but the added cost is probably justified. The changes to the API are limited to the diff_analysis module itself, and do not impact the general validation API whatsoever.
Bugs fixed
Allow /DR and /Version updates in diff analysis
Fix revision handling in trailer.flatten()
0.2.0
Release date: 2021-01-10
New features and enhancements
Signing
Allow the caller to specify an output stream when signing.
Validation
The incremental update analysis functionality has been heavily refactored into something more rule-based and modular. The new difference analysis system is also much more user-configurable, and a (sufficiently motivated) library user could even plug in their own implementation.
The new validation system treats
/Metadataupdates more correctly, and fixes a number of other minor stability problems.Improved validation logging and status reporting mechanisms.
Improved seed value constraint enforcement support: this includes added support for
/V,/MDP,/LockDocument,/KeyUsageand (passive) support for/AppearanceFilterand/LegalAttestation.
CLI
You can now specify negative page numbers on the command line to refer to the pages of a document in reverse order.
General PDF API
Added convenience functions to retrieve references from dictionaries and arrays.
Tweaked handling of object freeing operations; these now produce PDF
nullobjects instead of (Python)None.
Bugs fixed
root_refnow consistently returns aReferenceobjectCorrected wrong usage of
@freeze_timein tests that caused some failures due to certificate expiry issues.Fixed a gnarly caching bug in
HistoricalResolverthat sometimes leaked state from later revisions into older ones.Prevented cross-reference stream updates from accidentally being saved with the same settings as their predecessor in the file. This was a problem when updating files generated by other PDF processing software.
0.1.0
Release date: 2020-12-30
Initial release.
pyhanko-certvalidator
0.31.1
Release date: 2026-05-06
Bump
cryptographyto48.0.0.ML-DSA support.
0.31.0
Release date: 2026-05-03
Bump
cryptographyto47.0.0.Always short-circuit OCSP fetching if no URLs.
Tests and testability fixes for AdES TS handling.
Get rid of unnecessary
asyncmarker onget_session()in theaiohttpfetcher.Align default certs with certifi for
aiohttpusage.
0.30.2
Release date: 2026-03-27
Fix issue #648, causing OCSP responses to fail to be processed if the responder certificate’s subject key identifier is not generated in the standard way.
0.30.1
Release date: 2026-03-08
Address a packaging error with tests directory in sdists.
0.30.0
Release date: 2026-03-05
Drop support for Python 3.9
Drop TLS-specific validation code (breaking change)
Drop poorly supported whitelist feature (breaking change)
Remove deprecated methods from
ValidationContext(breaking change)Clean up test fixtures
Include tests in sdist again.
0.29.1
Release date: 2026-02-08
Fix inconsistent
aiohttpbounds.Add nonstandard
application/pkix-cacontent type.
0.29.0
Release date: 2025-09-12
Minor adjustments to error handling and APIs to handle validation context derivation from policies.
0.28.0
Release date: 2025-08-23
Remove unneeded Python 3.8 compatibility code
Improve test coverage for some more exotic CRL processing scenarios, simplify code accordingly.
Supply more info on freshness check failures, ensure time tolerance is accounted for.
Support time-limited roots.
Fix various bugs in AdES validation and the handling of non-default
TrustAnchorimplementations.Unify raw signature validation internals with pyHanko; make the validation implementation pluggable. See
SignatureValidator.
0.27.0
Release date: 2025-05-24
Integrated into pyHanko repository as separate sub-package.
No functional changes.
0.26.8
Release date: 2025-03-15
Fixed bug where an HTTP(S) CRL URI appearing next to an LDAP one as part of the same DP entry would not always be picked up.
Dramatically improved processing speed for large CRLs.
0.26.7
Release date: 2025-03-12
No functional changes.
0.26.6
Release date: 2025-03-12
Drop Python 3.7
List
qcStatementsas a known extension
0.26.5
Release date: 2024-11-17
Future-proofing against an upcoming
asn1cryptothat is already being shipped in some distro packages.Address some timing issues in tests.
0.26.4
Release date: 2024-11-12
Bump
aiohttprequirement to>=3.8,<3.11.Declare support for Python 3.12 and 3.13
0.26.3
Release date: 2023-12-13
Bump
aiohttprequirement to>=3.8,<3.10.Address two certificate fetching issues.
Tolerate CMS certificate-only message in response without
Content-Type.Deal with implicit reliance on order of certs when processing such messages.
0.26.2
Release date: 2023-11-18
Bump some dependency versions.
0.26.1
Release date: 2023-11-18
Handle nonspecific OCSP validation errors cleanly during validation.
0.26.0
Release date: 2023-11-14
Fix error reporting on banned algorithms in some cases
Allow caller to assert revocation status of a cert
More refined POE information tracking in experimental AdES API
0.25.0
Release date: 2023-10-06
Introduce a more precise error type to signal stale revocation information.
0.24.1
Release date: 2023-09-17
Ignore content types altogether when fetching certificates and the response payload is PEM.
0.24.0
Release date: 2023-09-07
Further increase leniency regarding content types when fetching certificates on-the-fly
Add SLSA provenance data to releases
Various updates in test dependencies and CI workflow dependencies.
0.23.0
Release date: 2023-05-14
Improve processing of OCSP responses without
nextUpdateSome more package metadata & release flow tweaks
0.22.0
Release date: 2023-04-23
No implementation changes compared to
0.21.2Renamed
async_httpdependency group toasync-http.Move towards automated GitHub Actions-based release flow as a move towards better process standardisation.
Sign release artifacts with Sigstore.
0.21.2
Release date: 2023-04-17
Fix a typing issue caused by a typo in the
requestscert fetcher.Removed a piece of misbehaving and duplicative logic in the revocation freshness checker.
0.21.1
Release date: 2023-04-02
Fix
DisallowedAlgorithmErrorparameters.Preserve timestamp info in expiration-related errors.
Disable algo enforcement in prima facie past validation checks.
Correct a misunderstanding in the interaction between the AdES code and the old “retroactive revinfo” setting.
0.21.0
Release date: 2023-04-01
Switch to
pyproject.tomlto manage project metadata.Path validation errors now carry information about the paths that triggered them.
InvalidCertificateErroris no longer a subclass ofPathValidationError, only ofValidationError. This is a minor but nonetheless breaking change.
0.20.1
Release date: 2023-02-21
Minor maintenance release without functional changes, only to metadata, documentation and typing.
0.20.0
Release date: 2023-01-23
This is a big release, with many breaking changes in the “deeper” APIs. The impact on the high-level API should be small to nonexistent, but caution when upgrading is advised.
More uniform and machine-processable errors.
Move towards a setup using “policy objects” that can be used to construct
ValidationContextobjects in a systematic way.Move revinfo gathering to a separate revinfo manager class. Some arguably internal methods on
ValidationContextwere moved to theRevinfoManagerclass.Incubating API for AdES validation primitives (freshness, POE handling, more sophisticated revinfo gathering, time slide) and some certificate-related validation routines.
Introduce a more fully-fledged API to manage permissible algorithms.
Broaden trust root provisioning beyond certificates: trust roots can now have qualifiers, and be provisioned as a name-key pair as opposed to a (self-signed) certificate. This implies breaking changes for
ValidationPath. In general, issuance semantics in the internals are now expressed through theAuthorityAPI as much as possible.In the same vein,
CertificateRegistrywas refactored intoTrustManager,CertificateRegistryandPathBuilder. These are respectively responsible for managing trust, maintaining the certificate cache, and building paths.Thorough clean-up of legacy dev tooling; put in place
mypyandblack, move topytest, get rid ofpretty_messagein favour of f-strings.
0.19.8
Release date: 2022-12-20
Fix double encoding when generating OCSP nonces
0.19.7
Release date: 2022-12-11
Make certificate fetcher more tolerant (see #2)
0.19.6
Release date: 2022-10-27
Update
asn1cryptoto1.5.1Declare Python 3.11 support
0.19.5
Release date: 2022-03-08
Maintenance update to bump
asn1cryptoto1.5.0and get rid of a number of compatibility shims for fixes that were upstreamed toasn1crypto.
0.19.4
Release date: 2022-02-10
Fix improper error handling when dealing with expired or not-yet-valid attribute certificates.
0.19.3
Release date: 2022-02-03
Correct and improve behaviour of certificate fetcher when the server does not supply a Content-Type header.
0.19.2
Release date: 2021-12-22
Patch
asn1cryptoto work around tagging issue in AC issuer field
0.19.1
Release date: 2021-12-22
Properly enforce algo matching in AC validation
0.19.0
Release date: 2021-12-14
Attribute certificate validation support
Support for
AAControlsextensionRefactored OCSP and CRL logic to work with attribute certificate validation
Many nominal type checks removed in favour of type annotations
Many API entry points now accept both
asn1crypto.x509.Certificateandasn1crypto.cms.AttributeCertificateV2Minor breaking change:
bytesis no longer acceptable as a substitute forasn1crypto.x509.Certificatein the public API
0.18.1
Release date: 2021-12-04
Various improvements to error handling in certificate fetchers
0.18.0
Release date: 2021-11-26
Replace
revocation_modewith more flexible revocation policy controls, aligned with ETSI TS 119 172. Oldrevocation_modeparams will be transparently translated to corresponding ‘refined’ policies, but therevocation_modeproperty onValidationContextwas removed.Handle soft fails as part of revocation policies. Concretely, this means that the
SoftFailErrorexception type was removed. Exceptions arising from quashed ‘soft’ failures can still be retrieved via thesoft_fail_exceptionsproperty onValidationContextinstances; the resulting list can contain any exception type.Fix various hiccups in CRL and OCSP handling.
0.17.4
Release date: 2021-11-13
Fix mistaken assumption when a certificate’s MIME type is announced as
application/x-x509-ca-cert.Update aiohttp to 3.8.0
0.17.3
Release date: 2021-10-28
Fix a deadlocking bug caused by improper exception handling in the fetcher code.
Exceptions are now communicated to fetch jobs waiting for results.
0.17.2
Release date: 2021-10-19
Replace
run_until_complete()withasyncio.run()for better event loop state management.
0.17.1
Release date: 2021-10-11
Fixes a packaging error in
0.17.0
0.17.0
Release date: 2021-10-11
Warning
This release contains breaking changes in lower-level APIs. High-level API functions should continue to work as-is, although some have been deprecated. However, the rewrite of the CRL & OCSP fetch logic breaks compatibility with the previous version’s API.
Refactor OCSP/certificate/CRL fetch logic to be more modular and swappable.
Automatically fetch missing issuer certificates if there is an AIA record indicating where to find them
Favour asynchronous I/O throughout the API.
CertificateValidator.validate_usage,CertificateValidator.validate_tlsand theValidationContext.retrieve_XYZmethods were deprecated in favour of their asynchronous equivalents.Support two backends for fetching revocation information and certificates:
requests(legacy) andaiohttp(via theasync-httpoptional dependency group).- It is expected that using
aiohttpfetchers will yield better performance with the asynchronous APIs, but as these require some resource management on the caller’s part,
requestsis still the default.
- It is expected that using
- Fetcher backends can be swapped out by means of the
fetcher_backendargument to ValidationContext.
- Fetcher backends can be swapped out by means of the
0.16.0
Release date: 2021-08-22
Refactor CertificateRegistry
Change OCSP responder cert selection procedure to give priority to certificates embedded into the response data (if there are any).
0.15.3
Release date: 2021-07-25
Short-circuit anyPolicy when reporting policies
Export PKIXValidationParams
Limit CRL client to HTTP-based URLs
0.15.2
Release date: 2021-05-22
Properly handle missing Content-Type header in server response when fetching CA certificates referenced in a CRL.
0.15.1
Release date: 2021-05-12
Gracefully handle lack of thisUpdate / nextUpdate in OCSP responses.
0.15.0
Release date: 2021-05-09
Use
pyca/cryptographyfor signature validation.oscryptois still included to access the system trust list.Support RSASSA-PSS and EdDSA certificates.
Support name constraints.
Support all input parameters to the PKIX validation algorithm (acceptable policy set, policy mapping inhibition, …).
Further increase PKITS coverage.
0.14.1
Release date: 2021-04-03
No code changes, rerelease because distribution package was polluted due to improper build cache cleanup.
0.14.0
Release date: 2021-04-03
Raise RequestError if CRL / OCSP client returns a status code other than 200. Previously, this would fail with a cryptic ASN.1 deserialisation error instead.
Rename Python package to
pyhanko_certvalidatorto avoid the potential name conflict with the upstreamcertvalidatorpackage.
0.13.1
Release date: 2021-03-24
Consider SHA-1 weak by default, and do not hard-code the list of potential weak hash algos.
0.13.0
Release date: 2021-03-19
Added an optional
retroactive_revinfoflag toValidationContextto ignore thethisUpdatefield in OCSP responses and CRLs. The effect of this is that CRLs and OCSP responses are also considered valid for point-in-time validation with respect to a time in the past. This is useful for some validation profiles. The default state of the flag remainsFalsenonetheless.
0.12.1
Release date: 2020-12-05
Fixed a packaging error.
0.12.0
Release date: 2020-12-05
Forked from certvalidator. to add patches for pyHanko.
Replaced urllib calls with
requestslibrary for universal mocking.Added a
time_toleranceparameter to the validation context to allow for some time drift on CRLs and OCSP responses.Deal with no-matches on OCSP and CRLs strictly in hard-fail mode.
Drop support for Python 2, and all Python 3 versions prior to 3.7. It is likely that the code still runs on older Python 3 versions, but I have no interest in maintaining support for those.
pyhanko-cli
0.4.0
Release date: 2026-05-03
Introduce
addsig identitysubcommand to allow recalling the parameters for specificaddsignsubcommands from configuration (incubating).Genericise password prompting in CLI.
Remove legacy LTV validation code, including all associated CLI hooks.
0.3.1
Release date: 2026-03-08
Address a packaging error with tests directory in sdists.
0.3.0
Release date: 2026-03-05
Drop support for Python 3.9
0.2.1
Release date: 2025-11-22
Maintenance release for Python 3.14 support.
0.2.0
Release date: 2025-09-12
Breaking changes
The
--ltv-profileargument topyhanko sign validateis now deprecated.The redundant
--apply-lta-timestampargument toltvfixwas removed.Some pieces of the configuration API were refactored or pushed fully into the CLI layer. This includes the way
CLIConfigdeals with validation context config.
New features and enhancements
Support EUTL usage and AdES validation in the CLI.
0.1.2
Release date: 2025-06-20
New features and enhancements
Auto-open document when validating an encrypted document using the CLI and there is no user password.
Support
--text-paramargument for stamps.
0.1.1
Release date: 2025-05-29
Dependency changes
Remove upper bound on
click(excluding version8.2.0as incompatible)
0.1.0
Release date: 2025-05-27
Initial release split off from main pyHanko distribution artifact.