2021年3月23日星期二

Python-Requests receive client private key as string instead of file path [duplicate]

I'm trying to use an encrypted client private key when using python requests. As it doesn't support encrypted keys, I have to decrypt it first and then send it to requests. The problem is that requests only accepts file paths for specifying client keys/certificates. How can I make it accept a string?

Example of what I want to do:

#X509  CLIENT_CERT_PATH = "path/to/cert" #perhaps I should convert this into a string too?    #PKey  CLIENT_PKEY_STRING = decrypt("path/to/encrypted_key")    response = requests.get(url = url, cert = (CLIENT_CERT_PATH, CLIENT_PKEY_STRING)) #how?  

Already tried Python requests CA certificates as a string but I got the following behaviour: ModuleNotFoundError: No module named 'OpenSSL' so I installed OpenSSL through pip install pyopenssl and ran my script again and got AttributeError: module 'urllib3.contrib' has no attribute 'pyopenssl'.

https://stackoverflow.com/questions/66771486/python-requests-receive-client-private-key-as-string-instead-of-file-path March 24, 2021 at 05:21AM

没有评论:

发表评论