Registry / auth-security / rfc3161-client

rfc3161-client

JSON →
library1.0.6pypypi✓ verified 85d ago

A Python client library for interacting with RFC 3161 compliant Timestamping Authorities (TSAs). It enables users to request timestamps for data and verify existing RFC 3161 timestamp responses. The library is actively maintained, with regular releases addressing bug fixes, security enhancements, and feature improvements, currently at version 1.0.6.

pip install rfc3161-client
INSTALL
IMPORT
SIG · RFC3161-CLIENT
R
rfc3161-client
auth-securitypythonv1.0.6
Install
2.6s avg
Import
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 40.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.6s · import 0.000s · 41MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TimeStampRequest
from rfc3161_client import TimeStampRequest
from rfc3161_client import TimestampRequest
TimeStampResponse
from rfc3161_client import TimeStampResponse
Verifier
from rfc3161_client import Verifier

This quickstart demonstrates how to request an RFC 3161 timestamp for a message hash and then verify the received response. It highlights the basic flow: hashing data, sending a `TimestampRequest`, and using a `VerifierBuilder` to confirm the authenticity and integrity of the timestamp.

import os import hashlib from rfc3161_client import TimestampRequest, VerifierBuilder, HashAlgorithm from rfc3161_client.exceptions import TSAResponseError, TimestampVerificationError # Use a public TSA URL. For production, ensure this is a trusted service. # Example: http://timestamp.digicert.com or a URL from your trusted provider. TSA_URL = os.environ.get('RFC3161_TSA_URL', 'http://timestamp.digicert.com') # 1. Prepare data to be timestamped message = b"This is the data to be timestamped." message_hash = hashlib.sha256(message).digest() print(f"Attempting to timestamp data using TSA: {TSA_URL}") # 2. Request a timestamp from the TSA try: request = TimestampRequest( tsa_url=TSA_URL, hashed_message=message_hash, hash_algorithm=HashAlgorithm.SHA256, ) timestamp_response = request.get_timestamp_response() print("Timestamp received successfully.") # 3. Verify the timestamp response # For robust verification, provide 'trusted_root_certs' of the TSA. # If not provided, the verifier attempts to build a chain from certs # embedded in the response or system CAs where possible (less secure). verifier = VerifierBuilder().build() is_valid = verifier.verify( timestamp_response=timestamp_response, hashed_message=message_hash, hash_algorithm=HashAlgorithm.SHA256, # trusted_root_certs=[b"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"], ) if is_valid: print("Timestamp verification successful.") else: print("Timestamp verification FAILED.") except TSAResponseError as e: print(f"Error from TSA: {e}") except TimestampVerificationError as e: print(f"Timestamp verification error: {e}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
gotchaPrior to v1.0.6, the verification process could incorrectly pick the leaf certificate during chain validation, potentially allowing an attacker to spoof a timestamp's origin if they could modify the response. This was a critical security vulnerability in verification.
fix
Upgrade to `rfc3161-client` `v1.0.6` or newer to ensure correct leaf certificate selection and secure timestamp verification.
affects: <= v1.0.5
gotchaBefore v1.0.4, timestamp verification did not correctly use the timestamp's creation time as the reference for certificate chain validity. This could lead to incorrect validation of older timestamps, where a certificate might have expired relative to the current time but was valid at the time the timestamp was issued.
fix
Upgrade to `rfc3161-client` `v1.0.4` or newer to align verification with RFC 3161, ensuring certificate chain validity is checked at the timestamp's creation time.
affects: <= v1.0.3
breakingThe return type of `VerifierBuilder.build()` was changed from `_Verifier` (a private class) to `Verifier` in v1.0.2. While `_Verifier` was not intended for direct use, code that type-hinted or explicitly accessed private attributes of `_Verifier` may break.
fix
Update any type hints or code that directly references `_Verifier` to use the public `Verifier` class instead. Typical usage `VerifierBuilder().build()` remains compatible.
affects: <= v1.0.1
gotchaAs of v1.0.1, the `Verifier` enforces that the Extended Key Usage (EKU) in the TSA's signing certificate explicitly includes the `id-kp-timeStamping` OID. If a TSA's certificate lacks this OID, verification will now fail where it might have implicitly succeeded in older versions.
fix
Ensure the TSA's certificate chain is correctly configured with the `id-kp-timeStamping` EKU. If you encounter verification failures, check the TSA certificate's EKUs and consult your TSA provider.
affects: <= v1.0.0
Upgrade
Version history
1.0.6latest on PyPI · released Apr 8, 2026
Audit
Dependencies
cryptographyrequiredProvides core cryptographic primitives for hash operations, certificate handling, and signature verification.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rfc3161-client — pip install rfc3161-client · libregistry