We have a lambda in AWS written in python 3.9 which calls a REST API which has authenticates SSL client cert. I am able to call the API on Postman with basic auth and a pfx cert file. However when I try to implement it in the lambda, I get SSL errors.
Here is the sample code which I use:
import urllib3
api_url = "https://..."
headers = urllib3.make_headers(basic_auth="xxx:yyy")
http = urllib3.PoolManager(cert_reqs="CERT_REQUIRED", cert_file="/tmp/abcd.pfx")
response = http.request('GET', api_url, headers=headers)
I store the ssl cert in S3 bucket and fetch and write it to /tmp before I call the API. I always get SSL error. I tried to pass the PEM as well as PFX files, nothing works
I have two questions:
- What is the best place to store the ssl client cert in AWS which can be used in the lambda?
- Is urllib3 the best way to connect to a REST API on ssl?
Would appreciate any pointers on this.