2

How can I add certificates (cert) to the requests.Session object in plain text?

I am now storing my certificatkey in AWS with Secrets Manager. The problem is that now I do not want to have a file on the server (I am using lambdas), now I want to load the certificate when I read it from AWS Secret Manager.

from requests import Session
from zeep import Client
from zeep.transports import Transport

cert = "I retrieve certificate from AWS Secrets manager"
key = "I retrieve key from AWS Secrets Manager"

session = Session()
session.cert = (cert, key)
transport = Transport(session=session)
client = Client(
    'http://my.own.sslhost.local/service?WSDL',
    transport=transport)

If I load it that way I get an error because it is not a path. I have tried several ways, but have not been able to do it. Does anyone know how to do it without specifying a path to a file? Or it is simply not possible.

RodriKing
  • 822
  • 2
  • 10
  • 20
  • Are you retrieving the keys’s content from the Key manager, or just a reference (name, etc.) to the key?? – Adam Smooch Jul 16 '21 at 18:03
  • @AdamSmooch I am retrieving the cert/key in plain text, previously created in my cert/key manager. Now I want to use it in the Session without path. – RodriKing Jul 16 '21 at 19:16
  • So ´session.cert’ is expecting a file path, and you are supplying file data? Check if there is a variant of that method that accepts the key data (doubtful), or save the key data to a file (e.g. in /tmp/key) and pass its path. – Adam Smooch Jul 17 '21 at 01:08

0 Answers0