3

我目前在我的代码中使用 SSL 客户端证书。我从 AWS SSM 读取证书,然后我必须将它们写入某个临时文件并将该文件传递给请求库。

# 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'))

我试图找到一种方法来避免将我的 SSL 密钥和证书写入本地文件。如果有人可以在这方面提供帮助,我将不胜感激。所以最终我想要这样的东西。

# 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))
4

0 回答 0