python requests post ssl certificate verify failed

Python Requests Post SSL Certificate Verify Failed

If you are experiencing a "Python Requests Post SSL Certificate Verify Failed" error, it means that the SSL certificate verification has failed while attempting to make a POST request using the Python Requests module. This can happen when the SSL certificate of the target website is not trusted or has expired.

Using Verify Parameter

The simplest way to fix this issue is to disable SSL certificate verification by setting the 'verify' parameter to False.


import requests

url = 'https://example.com'
data = {'key': 'value'}
response = requests.post(url, data=data, verify=False)

print(response.status_code)
  

Using Cert Parameter

Alternatively, you can specify the path to a trusted SSL certificate file using the 'cert' parameter.


import requests

url = 'https://example.com'
data = {'key': 'value'}
cert_file = '/path/to/certfile.pem'
response = requests.post(url, data=data, cert=cert_file)

print(response.status_code)
  

Updating CA Certificates

If none of the above solutions work, you may need to update your system's CA certificates. This can be done on Linux-based systems by installing the 'ca-certificates' package and running the 'update-ca-certificates' command.