Python Requests - SSL error for client side cert

后端 未结 1 1881
走了就别回头了
走了就别回头了 2020-12-14 19:09

I\'m calling a REST API with requests in python and so far have been successful when I set verify=False.

Now, I have to use client side cert that I need

相关标签:
1条回答
  • 2020-12-14 19:42

    I had this same problem. The verify parameter refers to the server's certificate. You want the cert parameter to specify your client certificate.

    import requests
    cert_file_path = "cert.pem"
    key_file_path = "key.pem"
    
    url = "https://example.com/resource"
    params = {"param_1": "value_1", "param_2": "value_2"}
    cert = (cert_file_path, key_file_path)
    r = requests.get(url, params=params, cert=cert)
    
    0 讨论(0)
提交回复
热议问题