Python code for sending requests with certificate, private encrypted key and password

Viewed 4612

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.

1 Answers
Related