Compare commits
7 Commits
test-ts-si
...
main
Author | SHA1 | Date | |
---|---|---|---|
0e7d01f0fd | |||
39b9f7455c | |||
97a2385167 | |||
77aaf97d7b | |||
dd8c30787a | |||
8c5950b37f | |||
df2a8d554f |
@ -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
|
@ -4,11 +4,10 @@ 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 pythonProject.timestamp import LocalOpensslTimestamp
|
from timestamp import LocalOpensslTimestamp
|
||||||
|
|
||||||
|
|
||||||
class SignOrchestrator:
|
class SignOrchestrator:
|
||||||
|
@ -12,7 +12,7 @@ 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)
|
||||||
@ -26,7 +26,7 @@ TSA_CONFIG_PATH = os.environ.get('TSA_CONFIG_PATH')
|
|||||||
TSA_CERT_CHAIN = os.environ.get('TSA_CERT_CHAIN')
|
TSA_CERT_CHAIN = os.environ.get('TSA_CERT_CHAIN')
|
||||||
TSA_KEY_PASSWORD = os.environ.get('TSA_KEY_PASSWORD')
|
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=os.environ.get('PKCS12_PASSWORD', None))
|
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())
|
||||||
|
|
||||||
parameters = pika.URLParameters(DSN)
|
parameters = pika.URLParameters(DSN)
|
||||||
connection = pika.BlockingConnection(parameters)
|
connection = pika.BlockingConnection(parameters)
|
||||||
@ -76,6 +76,7 @@ def on_message(channel, method_frame, header_frame, body):
|
|||||||
else:
|
else:
|
||||||
LOGGER.warning(f"first try failed, signatureId: {body_content['signatureId']}")
|
LOGGER.warning(f"first try failed, signatureId: {body_content['signatureId']}")
|
||||||
channel.basic_ack(delivery_tag=method_frame.delivery_tag)
|
channel.basic_ack(delivery_tag=method_frame.delivery_tag)
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -152,7 +152,7 @@ openssl ts -verify -data /etc/hosts -in /tmp/response.tsr -CAfile ca/root-ca.pem
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# Préparation pour Vendée
|
# Préparation à partir d'un certificat d'horodatage au format pkcs12
|
||||||
|
|
||||||
## Extraire les infos
|
## Extraire les infos
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user