3

I am currently using the SSL client-side certificate in my code. I read the cert from AWS SSM and then I have to write them to a temporary file somewhere and pass that file to the request library.

# read the cert and key from SSM and write to './client.cert' and './client.key' respectively
requests_session = requests.Session()
# send a request with SSL certificate
response = requests_session.post(url, headers=REQUEST_HEADER, json=request_body, timeout=TIMEOUT_IN_SECONDS,
    cert=('./client.cert', './client.key'))

I am trying to find a way to avoid writing my SSL key and cert to a local file. I would really appreciate if someone could help in this regard. So eventually I want something like this.

# read the cert and key from SSM
key = SSM.CLIENT_KEY
cert = SSM.CLIENT_CERT
requests_session = requests.Session()
# send a request with SSL certificate
response = requests_session.post(url, headers=REQUEST_HEADER, json=request_body, timeout=TIMEOUT_IN_SECONDS,
    cert=(cert, key))
Farhan Haider
  • 1,244
  • 1
  • 13
  • 22

0 Answers0