Use Session.verify=False

The alternate way of disabling the security check is using the Session present in requests module. We can declare the Session.verify=False instead of passing verify=True as parameter. Let’s look into the sample code so that one will get the clear picture of using Session.

Python3




import requests
 
# creating Session object and
# declaring the verify variable to False
session = requests.Session()
session.verify = False
 
# sending a get http request to specified url
response = requests.get("https://www.w3wiki.org/")
 
# response data
print(response.text)


Output



How to disable security certificate checks for requests in Python

In this article, we will discuss how to disable security certificate checks for requests in Python.

In Python, the requests module is used to send HTTP requests of a particular method to a specified URL. This request returns a response object that includes response data such as encoding, status, content, etc. But whenever we perform operations like get, post, delete, etc. 

We will get SSLCertVerificationError i.e., SSL:Certificate_Verify_Failed self-signed certificate. To get rid of this error there are two ways to disable the security certificate checks. They are

  • Passing verify=False to request method.
  • Use Session.verify=False

Similar Reads

Method 1: Passing verify=False to request method

The requests module has various methods like get, post, delete, request, etc. Each of these methods accepts an URL for which we send an HTTP request. Along with the URL also pass the verify=False parameter to the method in order to disable the security checks....

Method 2: Use Session.verify=False

...

Contact Us