python requests ssl certificate_verify_failed

Python Requests SSL Certificate_Verify_Failed

If you're using Python Requests library for making HTTPS requests, you might have come across a common error: "SSL Certificate_Verify_Failed". This error occurs because the SSL certificates provided by the website you are trying to access are not trusted by your system.

To fix this error, we need to tell Python Requests not to verify the SSL certificate. Here are a few ways to do it:

1. Disable SSL Verification

You can disable SSL verification by passing "verify=False" as a parameter while making the request.


      import requests

      url = 'https://example.com'
      response = requests.get(url, verify=False)

      print(response.content)
    

2. Add SSL Certificate

If you have the SSL certificate for the website, you can add it to your system's trusted certificates or pass it as a parameter while making the request.


      import requests

      url = 'https://example.com'
      ca_file = '/path/to/ca_file'
      response = requests.get(url, verify=ca_file)

      print(response.content)
    

3. Install Certifi Package

If you don't have the SSL certificate, you can install the certifi package which provides trusted certificates.


      import requests
      import certifi

      url = 'https://example.com'
      response = requests.get(url, verify=certifi.where())

      print(response.content)
    

By using any of the above methods, you can bypass the SSL certificate verification and make the HTTPS request successfully.