Skip to main content

A library for signing and timestamping file hashes

Project description

wacz-signing

test status

This package builds on work by Ilya Kreymer and Webrecorder in authsign. It is intended for use in WACZ signing (and to a lesser extent, verification), as set forth in the Webrecorder Recommendation WACZ Signing and Verification. It is an attempt to reduce authsign's footprint, and decouple signing from any specific web API, authentication, and the process of obtaining key material. It also omits the optional cross-signing mechanism specified in the recommendation and provided by authsign.

Perma Tools

Installation

For regular use, start a virtual environment and install this package and its requirements, something like this:

python3 -m venv env
. env/bin/activate
pip install wacz-signing

Use

The simplest way to use this system is to provide the environment variables DOMAIN and CERTNAME, possibly in a .env file; the package will then use the key material in /etc/letsencrypt/live/<CERTNAME>/. (The provision of DOMAIN is to accommodate the possibility that the domain name we care about is not the one that was originally used to create the cert.) Then, you can

>>> from wacz_signing import signer
>>> from datetime import datetime
>>> result = signer.sign('hello world!', datetime.utcnow())
>>> signer.verify(result)
{'observer': ['mkcert'], 'software': 'wacz-signing 0.2.6', 'timestamp': '2022-10-05T20:40:58Z'}

or

>>> signer.verify_wacz('test_files/valid_signed_example_1.wacz')
{'observer': ['btrix-sign-test.webrecorder.net'], 'software': 'authsigner 0.3.0', 'timestamp': '2022-01-18T19:00:12Z'}

You can also provide cert, key, and timestamper material directly, or in alternate files, using environment variables: you MUST provide DOMAIN; you MUST provide either CERTNAME or one of CERT and CERTFILE; if you have set CERTNAME, you MUST provide one of KEY and KEYFILE. If you're not using Letsencrypt certs, you'll need to set CERT_ROOTS. You may also configure the timestamper with TS_CERT or TS_CERTFILE and TS_URL and TS_ROOTS. You may additionally change the CERT_DURATION from its default of 7 days, and the STAMP_DURATION from its default of 10 minutes.

You may want to catch signer.SigningException and signer.VerificationException.

For local development and testing, you'll need to install mkcert. To generate certs and set up the environment, run

bash ./set-up-dot-env.sh

Certificate management

If you're using Letsencrypt certs, and you want them to be valid for a short duration, say the default of seven days, you would need to force a renewal after a week, then manually revoke the previous week's cert, something like

certbot renew --force-renewal --deploy-hook /path/to/deploy-hook-script

(or just put the script in /etc/letsencrypt/renewal-hooks/deploy/

where the script runs something like

certbot revoke --cert-path `ls -t /etc/letsencrypt/archive/${CERTNAME}/cert*.pem | head -n 2 | tail -n 1` --reason expiration

(But triple-check this before attempting it in earnest; a correct example may follow.)

Use cases

This package could be used in a tiny web API, of course; see examples/web-api/. It could also be integrated into a producer of WACZ files, like a future version of Perma, which would sign archives internally; it could also be run in a lambda, which is why it's possible to provide key material directly in environment variables.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wacz_signing-0.4.2.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wacz_signing-0.4.2-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file wacz_signing-0.4.2.tar.gz.

File metadata

  • Download URL: wacz_signing-0.4.2.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.5 Darwin/24.3.0

File hashes

Hashes for wacz_signing-0.4.2.tar.gz
Algorithm Hash digest
SHA256 05daf75878f7a543e4f171b6c7aa62479c044c624e4baded9077866ee1c20afd
MD5 214240de49578d9d275a702eac10fdfc
BLAKE2b-256 32befc77ece64bb666df51391296eab97837b897971c4da2b2d789dd53dfc1cd

See more details on using hashes here.

File details

Details for the file wacz_signing-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: wacz_signing-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.5 Darwin/24.3.0

File hashes

Hashes for wacz_signing-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4800c224414e54d0f23e24359ecf2d33123e96f7349a0090053b078b7fb7a8ad
MD5 844091c5073b2f0257a65ef0aa6b4118
BLAKE2b-256 ce8eca2dce6d069a31f63d0df4e62058f99bbd3a1e2bb9f224f097c1d711f8d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page