Reputation: 2000
I'm trying to fetch response from an https call which has certificate installed atits side. This is my code
import requests
import urllib3
urllib3.disable_warnings()
cert_file_path = "/path/output-crt-file-name.crt"
key_file_path = "/path/output-key-file-name.key"
passwd = 'secretpass'
print(passwd)
url = "https://url/to/fetch/response"
params = {"AppID": "xxxx", "Safe": "xxxx", "Folder": "Root",
"Object": "xxxx"}
cert = (cert_file_path, key_file_path, passwd)
r = requests.get(url, params=params, cert=cert, verify=True )
print(r.text)
which throws error
Caused by SSLError('Client private key is encrypted, password is required'
Please suggest.
Upvotes: 4
Views: 12129
Reputation: 1140
I'm afraid requests doesn't currently support using encrypted private key, see https://2.python-requests.org/en/master/user/advanced/#client-side-certificates:
The private key to your local certificate must be unencrypted. Currently, Requests does not support using encrypted keys.
See https://security.stackexchange.com/questions/59136/can-i-add-a-password-to-an-existing-private-key for instructions how to remove your key's encryption.
Upvotes: 5