Add new TSA configuration environment variables
All checks were successful
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.
This commit is contained in:
Julien Fastré 2024-10-21 18:53:46 +02:00
parent dd8c30787a
commit 77aaf97d7b
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 5 additions and 1 deletions

View File

@ -5,3 +5,6 @@ TIMESTAMP_URL=http://freetsa.org/tsr
QUEUE_IN=to_python_sign
EXCHANGE_OUT=signed_docs
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

View File

@ -12,7 +12,7 @@ logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__)
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', 'TIMESTAMP_URL', 'QUEUE_IN', 'EXCHANGE_OUT', 'OUT_ROUTING_KEY', 'TSA_CONFIG_PATH', 'TSA_CERT_CHAIN', 'TSA_KEY_PASSWORD']:
if v not in os.environ:
LOGGER.error('Missing environment variable: %s', v)
raise ValueError('Missing environment variable: ' + v)
@ -76,6 +76,7 @@ def on_message(channel, method_frame, header_frame, body):
else:
LOGGER.warning(f"first try failed, signatureId: {body_content['signatureId']}")
channel.basic_ack(delivery_tag=method_frame.delivery_tag)
raise e
if __name__ == '__main__':