Search code examples
python-3.xamazon-web-servicesgunicornfastapi

Accessing Certificate and Key from AWS secrets manager to be used in Gunicorn configuration


I have store a ssl cert file and key file in AWS secrets manager. I need to use those files for running gunicorn in HTTPS mode using following commnand:

gunicorn --certfile=server.crt --keyfile=server.key test:app

How can I access this?


Solution

  • If this is a certificate issued by AWS ACM, then you can't export the private key so you won't be able to use it like this. If this is a certificate issued by some other service that you have imported into AWS ACM, then you can get the key files with the aws acm export-certificate AWS CLI command.

    You would have to run the AWS CLI command to export the certificate, then run the openssl command also detailed in the documentation I linked to decrypt the private key, and save all that to the file system before running your gunicorn command.