Author SHA1 Message Date
renovate-bot eaec025901 Update dependency pyhanko-certvalidator to v0.31.4 2026-11-19 02:19:47 +00:00
julienfastre 81a585f546 Merge pull request 'Pin dependencies' (#5) from renovate/pin-dependencies into main
Build image and push it to registry / build (push) Successful in 32s
Reviewed-on: #5
2026-11-18 08:34:32 +00:00
renovate-bot bec337882c Pin dependencies 2026-11-18 02:19:05 +00:00
julienfastre bac18a832a Merge pull request 'Configure Renovate' (#4) from renovate/configure into main
Build image and push it to registry / build (push) Successful in 40s
Reviewed-on: #4
2026-11-17 19:37:38 +00:00
renovate-bot 9afef46888 Add renovate.json 2026-09-29 11:06:01 +00:00
julienfastre adba75fd24 Add byUserId to message payload in worker for enhanced metadata
Build image and push it to registry / build (push) Successful in 1m25s
2026-05-20 22:41:46 +02:00
julienfastre 7c1d645447 Update dependencies in requirements.txt to latest versions
Build image and push it to registry / build (push) Successful in 1m23s
2026-05-20 16:00:48 +02:00
julienfastreandClaude Sonnet 4.6 dadf3d72e3 Fix infinite retry loop on signing errors in worker
Catch SigningError separately (logged at ERROR level) and fix the ack/nack
logic so failed messages are requeued once then discarded, instead of being
requeued indefinitely or lost. Remove the bare `raise e` that crashed the
worker after each error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 15:36:54 +02:00
julienfastre 083bf20be7 update deps, switching pyhanko to version 0.29
Build image and push it to registry / build (push) Successful in 2m0s
2025-06-05 13:33:38 +02:00
julienfastre 6626b33c6a upgrade idea settings 2025-06-05 13:33:38 +02:00
julienfastre 8a3c44c517 test signature with return line 2025-06-05 13:33:38 +02:00
julienfastre c7a6283e00 Add timezone configuration to Dockerfile
Build image and push it to registry / build (push) Successful in 1m11s
Included tzdata package and set the timezone to Europe/Paris by creating a symbolic link in /etc/localtime. This ensures the container runs with the correct timezone settings.
2024-11-06 14:46:45 +01:00
julienfastre 0e7d01f0fd Fix environment password encoding in SignOrchestrator init
Build image and push it to registry / build (push) Successful in 6m47s
Previously, the `PKCS12_PASSWORD` environment variable was used directly, which could lead to issues when it was not set. This change ensures the password is properly encoded when provided and defaults to `None` if not set.
2024-10-22 16:37:49 +02:00
julienfastre 39b9f7455c Update README section title for clarity
Changed the title "Préparation pour Vendée" to "Préparation à partir d'un certificat d'horodatage au format pkcs12" for better clarity and specificity. This update helps users understand the section's purpose more easily.
2024-10-22 16:37:31 +02:00
julienfastre 97a2385167 Remove redundant 'TIMESTAMP_URL' environment variable check
Build image and push it to registry / build (push) Successful in 1m27s
The 'TIMESTAMP_URL' environment variable check was removed from the worker script as it is no longer required. This simplifies the code by eliminating unnecessary validation.
2024-10-22 12:07:08 +02:00
julienfastre 77aaf97d7b Add new TSA configuration environment variables
Build image and push it to registry / build (push) Successful in 1m1s
Included 'TSA_CONFIG_PATH', 'TSA_CERT_CHAIN', and 'TSA_KEY_PASSWORD' to the environment variable check in worker.py. This ensures the script validates these new required configurations before proceeding. Added an exception raise in the error handling block for better error management.
2024-10-21 18:53:52 +02:00
julienfastre dd8c30787a fix imports
Build image and push it to registry / build (push) Successful in 1m48s
2024-10-21 18:28:20 +02:00
julienfastre 8c5950b37f Merge pull request 'Allow the signature_index to be None' (#3) from test-ts-sign into main
Build image and push it to registry / build (push) Successful in 1m40s
Reviewed-on: #3
2024-10-16 07:13:38 +00:00
julienfastre 34857ae4b0 Allow the signature_index to be None
When the signature_index is not set, the name's sinature zone is generated from a random int.
2024-10-15 07:47:58 +02:00
julienfastre df2a8d554f Merge pull request 'Create a dedicated timestamper which use the openssl cli and custom certificates' (#2) from test-ts-sign into main
Build image and push it to registry / build (push) Successful in 1m42s
Reviewed-on: #2
2024-10-11 14:19:51 +00:00
julienfastre 89cb05fce1 Add openssl to Dockerfile
This change adds the openssl CLI to the Dockerfile to ensure necessary cryptographic functionalities are available. It helps in maintaining secure communications and other operations that depend on openssl.
2024-10-11 16:19:32 +02:00
julienfastre 3716c3ce78 create a new script dedicated for signing for vendee certificates 2024-10-11 16:13:34 +02:00
julienfastre c8042a6f84 Integrate local OpenSSL TSA for timestamping
Replaced HTTPTimeStamper with LocalOpensslTimestamp for TSA operations using a local OpenSSL CLI. Updated related configurations and dependencies to support this change, enhancing the timestamping process's reliability and security.
2024-10-11 16:13:34 +02:00
15 changed files with 245 additions and 52 deletions

No files matched your search

+4 -4
View File
@@ -16,20 +16,20 @@ jobs:
runs-on: cth-ubuntu-latest runs-on: cth-ubuntu-latest
steps: steps:
- name: Check out repository - name: Check out repository
uses: https://github.com/actions/checkout@v4 uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3 uses: https://github.com/docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Login to registry - name: Login to registry
uses: https://github.com/docker/login-action@v3 uses: https://github.com/docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: 'h3m6q87t.gra7.container-registry.ovh.net' registry: 'h3m6q87t.gra7.container-registry.ovh.net'
- name: Build and push - name: Build and push
uses: https://github.com/docker/build-push-action@v5 uses: https://github.com/docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
with: with:
context: ./pythonProject context: ./pythonProject
file: ./pythonProject/Dockerfile file: ./pythonProject/Dockerfile
+1 -1
View File
@@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Python 3.10 (pythonProject)" /> <option name="sdkName" value="Python 3.10 (pythonProject)" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pythonProject)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 virtualenv at ~/dev/chill/sign-pdf-worker/pythonProject/.venv" project-jdk-type="Python SDK" />
</project> </project>
+1 -1
View File
@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/pythonProject/.venv" /> <excludeFolder url="file://$MODULE_DIR$/pythonProject/.venv" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.10 virtualenv at ~/dev/chill/sign-pdf-worker/pythonProject/.venv" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
+3
View File
@@ -5,3 +5,6 @@ TIMESTAMP_URL=http://freetsa.org/tsr
QUEUE_IN=to_python_sign QUEUE_IN=to_python_sign
EXCHANGE_OUT=signed_docs EXCHANGE_OUT=signed_docs
OUT_ROUTING_KEY=signed_doc OUT_ROUTING_KEY=signed_doc
TSA_CONFIG_PATH=/home/julien/dev/chill/sign-pdf-worker/ts-authority/rootca.conf
TSA_CERT_CHAIN=/home/julien/dev/chill/sign-pdf-worker/ts-authority/ca/tsa-chain.pem
TSA_KEY_PASSWORD=5678
+7 -1
View File
@@ -1,9 +1,15 @@
# Set base Python image version # Set base Python image version
FROM python:3.10-alpine FROM python:3.10-alpine@sha256:8ca9f9d0f4df2af674092e7e9d79ce7985e783cecfe070f8ea850801b6520bf7
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
# add required clis
RUN apk add --no-cache openssl tzdata
# set timezone
RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
# Copy requirements.txt to the Docker container # Copy requirements.txt to the Docker container
COPY requirements.txt . COPY requirements.txt .
+19 -17
View File
@@ -1,20 +1,22 @@
asn1crypto==1.5.1 asn1crypto==1.5.1
certifi==2024.6.2 certifi==2026.5.20
cffi==1.16.0 cffi==2.0.0
charset-normalizer==3.3.2 charset-normalizer==3.4.7
click==8.1.7 click==8.4.0
cryptography==42.0.8 cryptography==48.0.0
idna==3.7 idna==3.15
lxml==6.1.1
oscrypto==1.3.0 oscrypto==1.3.0
pika==1.3.2 pika==1.4.0
pycparser==2.22 pika-stubs==0.1.3
pyHanko==0.25.0 pycparser==3.0
pyhanko-certvalidator==0.26.3 pyHanko==0.35.1
pyhanko-certvalidator==0.31.4
pypng==0.20220715.0 pypng==0.20220715.0
PyYAML==6.0.1 PyYAML==6.0.3
qrcode==7.4.2 qrcode==8.2
requests==2.32.3 requests==2.34.2
typing_extensions==4.12.2 typing_extensions==4.15.0
tzlocal==5.2 tzlocal==5.3.1
uritools==4.0.3 uritools==6.1.1
urllib3==2.2.2 urllib3==2.7.0
+10 -8
View File
@@ -1,17 +1,21 @@
import io import io
from random import randint
from typing import Optional from typing import Optional
from pyhanko import stamp from pyhanko import stamp
from pyhanko.pdf_utils.incremental_writer import IncrementalPdfFileWriter from pyhanko.pdf_utils.incremental_writer import IncrementalPdfFileWriter
from pyhanko.sign import signers, timestamps, fields from pyhanko.sign import signers, fields
from pyhanko_certvalidator import ValidationContext
from typing_extensions import Buffer from typing_extensions import Buffer
from timestamp import LocalOpensslTimestamp
class SignOrchestrator: class SignOrchestrator:
"""Orchestrate the signature on document""" """Orchestrate the signature on document"""
def __init__(self, pkcs12_path: str, timestamp_url: str, pkcs12_password: Optional[bytes] = None): def __init__(self, pkcs12_path: str,
tsa_config_path: str, tsa_password: str, tsa_cert_chain: str,
pkcs12_password: Optional[bytes] = None):
# Load signer key material from PKCS#12 file # Load signer key material from PKCS#12 file
# This assumes that any relevant intermediate certs are also included # This assumes that any relevant intermediate certs are also included
# in the PKCS#12 file. # in the PKCS#12 file.
@@ -20,9 +24,7 @@ class SignOrchestrator:
) )
# Set up a timestamping client to fetch timestamps tokens # Set up a timestamping client to fetch timestamps tokens
self.timestamper = timestamps.HTTPTimeStamper( self.timestamper = LocalOpensslTimestamp(tsa_config_path, tsa_password, tsa_cert_chain)
url=timestamp_url,
)
self.stamp_style = stamp.TextStampStyle( self.stamp_style = stamp.TextStampStyle(
stamp_text="Signé par:\n%(signer_text)s\nLe %(ts)s", stamp_text="Signé par:\n%(signer_text)s\nLe %(ts)s",
@@ -47,8 +49,8 @@ class SignOrchestrator:
reason=reason, reason=reason,
) )
def sign(self, reason: str, signature_index: int, input_content: Buffer, on_page: int, box_place: (int, int, int, int), signer_text: str) -> io.BytesIO: def sign(self, reason: str, signature_index: int|None, input_content: Buffer, on_page: int, box_place: (int, int, int, int), signer_text: str) -> io.BytesIO:
field_name = 'Signature' + str(signature_index) field_name = 'Signature' + str(signature_index) if signature_index is not None else 'Signature'+ str(randint(1000, 99999999999))
signature_meta = self._make_signature_metadata(reason, field_name) signature_meta = self._make_signature_metadata(reason, field_name)
pdf_signer = signers.PdfSigner( pdf_signer = signers.PdfSigner(
+22 -8
View File
@@ -1,19 +1,33 @@
from sign import SignOrchestrator from sign import SignOrchestrator
orchestrator = SignOrchestrator('./assets/dummy.p12','http://freetsa.org/tsr', pkcs12_password=None) """
This is a script to sign a file with the dummy assets
It is created mainly for testing purpose
"""
orchestrator = SignOrchestrator('./assets/dummy.p12',
'/home/julien/dev/chill/sign-pdf-worker/ts-authority/rootca.conf',
'5678',
'/home/julien/dev/chill/sign-pdf-worker/ts-authority/ca/tsa-chain.pem',
pkcs12_password=None)
with open('./assets/test.pdf', 'rb') as input: with open('./assets/test.pdf', 'rb') as input:
signed_content = orchestrator.sign(reason="first signer", signature_index=0, signed_content = orchestrator.sign(reason="first\nsigner\nreturn\ntext", signature_index=None,
input_content=input.read(), box_place=(300, 600, 500, 660), on_page=0, input_content=input.read(), box_place=(300, 600, 500, 660), on_page=0,
signer_text="Mme Caroline Diallo") signer_text="""Mme Caroline Diallo
with
return
text
""")
with open('./assets/test_signed_0.pdf', 'wb') as output: with open('./assets/test_signed_0.pdf', 'wb') as output:
output.write(signed_content.read()) output.write(signed_content.read())
with open('./assets/test_signed_0.pdf', 'rb') as input: with open('./assets/test_signed_0.pdf', 'rb') as input:
signed_content = orchestrator.sign(reason="second signer", signature_index=1, signed_content = orchestrator.sign(reason="second signer", signature_index=None,
input_content=input.read(), box_place=(100, 600, 300, 660), on_page=0, input_content=input.read(), box_place=(100, 600, 300, 660), on_page=0,
signer_text="M. Bah Mamadou") signer_text="M. Bah Mamadou")
with open('./assets/test_signed_1.pdf', 'wb') as output: with open('./assets/test_signed_1.pdf', 'wb') as output:
output.write(signed_content.read()) output.write(signed_content.read())
@@ -0,0 +1,29 @@
from sign import SignOrchestrator
"""
This is a script to sign a file with the dummy assets
It is created mainly for testing purpose
"""
orchestrator = SignOrchestrator('/run/user/1000/ca/cachet.p12',
'/home/julien/dev/chill/sign-pdf-worker/ts-authority/vendee-tsa.conf',
'xxxxxxxxxxxxxxxxxxx',
'/run/user/1000/ca/tsa-chain.pem',
pkcs12_password=b"xxxxxxxxxxxxxxxx")
with open('./assets/test.pdf', 'rb') as input:
signed_content = orchestrator.sign(reason="first signer", signature_index=0,
input_content=input.read(), box_place=(300, 600, 500, 660), on_page=0,
signer_text="Mme Caroline Diallo")
with open('./assets/test_signed_0.pdf', 'wb') as output:
output.write(signed_content.read())
with open('./assets/test_signed_0.pdf', 'rb') as input:
signed_content = orchestrator.sign(reason="second signer", signature_index=1,
input_content=input.read(), box_place=(100, 600, 300, 660), on_page=0,
signer_text="M. Bah Mamadou")
with open('./assets/test_signed_1.pdf', 'wb') as output:
output.write(signed_content.read())
+64
View File
@@ -0,0 +1,64 @@
import logging
import os
from asn1crypto import tsp
from asn1crypto.tsp import TimeStampResp
from pyhanko.sign.timestamps import TimeStamper
import subprocess
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(os.environ.get('LOG_LEVEL', logging.DEBUG))
class LocalOpensslTimestamp(TimeStamper):
"""
Apply a timestamp using a local openssl cli.
The class provides methods to request a timestamp response from a local OpenSSL TSA cli.
"""
def __init__(self, path_config: str, password: str, path_chain: str):
super().__init__()
self.path_conf = path_config
self.password = password
self.path_chain = path_chain
def request_tsa_response(self, req: tsp.TimeStampReq) -> tsp.TimeStampResp:
with open('/tmp/request.tsq', 'wb') as request:
request.write(req.dump())
cmd = [
'openssl', 'ts', '-reply',
'-config', self.path_conf,
'-queryfile', '/tmp/request.tsq',
'-chain', self.path_chain,
'-out', '/tmp/response.tsr',
'-passin', f'pass:{self.password}'
]
try:
subprocess.run(cmd, capture_output=True, check=True, timeout=10)
except subprocess.CalledProcessError as e:
LOGGER.error("Could not generate a timestamp")
LOGGER.error(f"response code: {e.returncode}")
LOGGER.error(f"stderr: {e.stderr}")
LOGGER.error(f"stdout: {e.stdout}")
LOGGER.error(f"error: {e.output}")
raise Exception("could not generate a timestamp")
except subprocess.TimeoutExpired as e:
LOGGER.error("timeout expired")
LOGGER.error(f"stderr: {e.stderr}")
LOGGER.error(f"stdout: {e.stdout}")
LOGGER.error(f"error: {e.output}")
raise e
with open('/tmp/response.tsr', mode='rb') as f:
tsp = TimeStampResp.load(f.read())
os.unlink('/tmp/response.tsr')
return tsp
async def async_request_tsa_response(self, req: tsp.TimeStampReq) -> tsp.TimeStampResp:
return self.request_tsa_response(req)
+21 -11
View File
@@ -5,6 +5,7 @@ import os
import pika import pika
import sign import sign
from pyhanko.sign.general import SigningError
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) ' LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s') '-35s %(lineno) -5d: %(message)s')
@@ -12,20 +13,21 @@ logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(os.environ.get('LOG_LEVEL', logging.INFO)) LOGGER.setLevel(os.environ.get('LOG_LEVEL', logging.INFO))
for v in ['AMQP_URL', 'PKCS12_PATH', 'TIMESTAMP_URL', 'QUEUE_IN', 'EXCHANGE_OUT', 'OUT_ROUTING_KEY']: for v in ['AMQP_URL', 'PKCS12_PATH', 'QUEUE_IN', 'EXCHANGE_OUT', 'OUT_ROUTING_KEY', 'TSA_CONFIG_PATH', 'TSA_CERT_CHAIN', 'TSA_KEY_PASSWORD']:
if v not in os.environ: if v not in os.environ:
LOGGER.error('Missing environment variable: %s', v) LOGGER.error('Missing environment variable: %s', v)
raise ValueError('Missing environment variable: ' + v) raise ValueError('Missing environment variable: ' + v)
DSN = os.environ.get('AMQP_URL') DSN = os.environ.get('AMQP_URL')
PKCS12_PATH = os.environ.get('PKCS12_PATH') PKCS12_PATH = os.environ.get('PKCS12_PATH')
TIMESTAMP_URL = os.environ.get('TIMESTAMP_URL')
QUEUE_IN = os.environ.get('QUEUE_IN') QUEUE_IN = os.environ.get('QUEUE_IN')
EXCHANGE_OUT = os.environ.get('EXCHANGE_OUT') EXCHANGE_OUT = os.environ.get('EXCHANGE_OUT')
OUT_ROUTING_KEY = os.environ.get('OUT_ROUTING_KEY') OUT_ROUTING_KEY = os.environ.get('OUT_ROUTING_KEY')
TSA_CONFIG_PATH = os.environ.get('TSA_CONFIG_PATH')
TSA_CERT_CHAIN = os.environ.get('TSA_CERT_CHAIN')
TSA_KEY_PASSWORD = os.environ.get('TSA_KEY_PASSWORD')
orchestrator = sign.SignOrchestrator(PKCS12_PATH, TSA_CONFIG_PATH, TSA_KEY_PASSWORD, TSA_CERT_CHAIN, pkcs12_password=None if os.environ.get('PKCS12_PASSWORD', None) is None else os.environ.get('PKCS12_PASSWORD').encode())
orchestrator = sign.SignOrchestrator(PKCS12_PATH, TIMESTAMP_URL, pkcs12_password=os.environ.get('PKCS12_PASSWORD', None))
parameters = pika.URLParameters(DSN) parameters = pika.URLParameters(DSN)
connection = pika.BlockingConnection(parameters) connection = pika.BlockingConnection(parameters)
@@ -59,6 +61,7 @@ def on_message(channel, method_frame, header_frame, body):
channel.basic_publish(exchange=EXCHANGE_OUT, channel.basic_publish(exchange=EXCHANGE_OUT,
body=json.dumps({'signatureId': body_content['signatureId'], body=json.dumps({'signatureId': body_content['signatureId'],
'signatureZoneIndex': body_content['signatureZoneIndex'], 'signatureZoneIndex': body_content['signatureZoneIndex'],
'byUserId': body_content['byUserId'] if 'byUserId' in body_content else None,
'content': base64.b64encode(signed.read()).decode('utf-8')}), 'content': base64.b64encode(signed.read()).decode('utf-8')}),
properties=pika.BasicProperties(content_type='application/json', properties=pika.BasicProperties(content_type='application/json',
delivery_mode=pika.DeliveryMode.Transient), delivery_mode=pika.DeliveryMode.Transient),
@@ -66,15 +69,22 @@ def on_message(channel, method_frame, header_frame, body):
LOGGER.debug("signed file resend to amqp") LOGGER.debug("signed file resend to amqp")
channel.basic_ack(delivery_tag=method_frame.delivery_tag) channel.basic_ack(delivery_tag=method_frame.delivery_tag)
except Exception as e: except SigningError as e:
LOGGER.warning(f"error encountered while signing: {e}") LOGGER.error(f"signing error for signatureId {body_content['signatureId']}: {e}", exc_info=True)
if method_frame.redelivered: if method_frame.redelivered:
LOGGER.warning( LOGGER.error(f"message already redelivered, discarding signatureId: {body_content['signatureId']}")
f"stopping handling this message, because the message is already redelivered, signatureId: {body_content['signatureId']}") channel.basic_reject(delivery_tag=method_frame.delivery_tag, requeue=False)
channel.basic_reject(delivery_tag=method_frame.delivery_tag, requeue=True)
else: else:
LOGGER.warning(f"first try failed, signatureId: {body_content['signatureId']}") LOGGER.warning(f"first try failed, requeueing for one retry, signatureId: {body_content['signatureId']}")
channel.basic_ack(delivery_tag=method_frame.delivery_tag) channel.basic_nack(delivery_tag=method_frame.delivery_tag, requeue=True)
except Exception as e:
LOGGER.warning(f"error encountered while signing, signatureId: {body_content['signatureId']}: {e}", exc_info=True)
if method_frame.redelivered:
LOGGER.warning(f"message already redelivered, discarding signatureId: {body_content['signatureId']}")
channel.basic_reject(delivery_tag=method_frame.delivery_tag, requeue=False)
else:
LOGGER.warning(f"first try failed, requeueing for one retry, signatureId: {body_content['signatureId']}")
channel.basic_nack(delivery_tag=method_frame.delivery_tag, requeue=True)
if __name__ == '__main__': if __name__ == '__main__':
+3
View File
@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}
+14
View File
@@ -151,3 +151,17 @@ The OK response ensures that the original signed timestamp is correctly authoriz
openssl ts -verify -data /etc/hosts -in /tmp/response.tsr -CAfile ca/root-ca.pem -untrusted ca/tsa.pem openssl ts -verify -data /etc/hosts -in /tmp/response.tsr -CAfile ca/root-ca.pem -untrusted ca/tsa.pem
``` ```
# Préparation à partir d'un certificat d'horodatage au format pkcs12
## Extraire les infos
```bash
openssl pkcs12 -info -in horodatage.p12 -legacy
```
Ca demandera un mot de passe pour déchiffrer, et un autre mot de passe pour chiffrer la clé qui apparaitra.
- on recopie la clé et on fait un copier-coller dans /run/user/1000/ca/private/tsa.key
- on recopie tous les certificats, on supprime les interligne, et on colle ça dans /run/user/1000/ca/tsa-chain.pem
- on recopie le premier certificat, pour céer /run/user/1000/ca/tsa.crt
+1 -1
View File
@@ -138,7 +138,7 @@ subjectKeyIdentifier = hash
default_tsa = tsa_config1 default_tsa = tsa_config1
[ tsa_config1 ] [ tsa_config1 ]
dir = . # TSA root directory, same as root-ca dir = /home/julien/dev/chill/sign-pdf-worker/ts-authority # TSA root directory, same as root-ca
serial = $dir/ca/tsa_serial # current serial number (mandatory) serial = $dir/ca/tsa_serial # current serial number (mandatory)
signer_cert = $dir/ca/tsa.crt # signing certificate (optional) signer_cert = $dir/ca/tsa.crt # signing certificate (optional)
certs = $dir/ca/tsa-chain.pem # certification chain (optional) certs = $dir/ca/tsa-chain.pem # certification chain (optional)
+46
View File
@@ -0,0 +1,46 @@
#
# rootca.conf
#
# See Ristic OpenSSL Cookbook URL above.
oid_section = new_oids
[ new_oids ]
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7
[ tsa ]
default_tsa = tsa_config1
[ tsa_config1 ]
dir = /run/user/1000/ca # TSA root directory, same as root-ca
serial = $dir/tsa_serial # current serial number (mandatory)
signer_cert = $dir/tsa.crt # signing certificate (optional)
certs = $dir/tsa-chain.pem # certification chain (optional)
signer_key = $dir/private/tsa.key # tsa private key (optional)
default_policy = tsa_policy1
signer_digest = sha256 # digest to use for signing (optional)
other_policies = tsa_policy2,tsa_policy3 # other policies (optional)
digests = sha256,sha384,sha512 # acceptable digests (mandatory)
accuracy = secs:1,millisecs:500,microsecs:100 # accuracy optional
ordering = yes # is ordering defined? (optional, default: no)
tsa_name = yes # must tsa name be included in reply? (opt., default: no)
ess_cert_id_chain = yes # must ess cert id change be incl? (opt., default: no)
ess_cert_id_alg = sha256 # alg to compute cert. id (optional, default: sha1)
# added, was missing in the blog post
crypto_device = builtin
# The tsa_ext extension is
# used to create the tsa cert tsa.crt
[ tsa_ext ]
authorityKeyIdentifier = keyid:always
basicConstraints = critical,CA:false
extendedKeyUsage = critical,timeStamping
keyUsage = critical,nonRepudiation
subjectKeyIdentifier = hash