From the documentation:

requests can also ignore verifying the SSL certificate if you set verify to False.

>>> requests.get('https://kennethreitz.com', verify=False)
<Response [200]>

If you're using a third-party module and want to disable the checks, here's a context manager that monkey patches requests and changes it so that verify=False is the default and suppresses the warning.

import warnings
import contextlib

import requests
from urllib3.exceptions import InsecureRequestWarning

old_merge_environment_settings = requests.Session.merge_environment_settings

@contextlib.contextmanager
def no_ssl_verification():
    opened_adapters = set()

    def merge_environment_settings(self, url, proxies, stream, verify, cert):
        # Verification happens only once per connection so we need to close
        # all the opened adapters once we're done. Otherwise, the effects of
        # verify=False persist beyond the end of this context manager.
        opened_adapters.add(self.get_adapter(url))

        settings = old_merge_environment_settings(self, url, proxies, stream, verify, cert)
        settings['verify'] = False

        return settings

    requests.Session.merge_environment_settings = merge_environment_settings

    try:
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', InsecureRequestWarning)
            yield
    finally:
        requests.Session.merge_environment_settings = old_merge_environment_settings

        for adapter in opened_adapters:
            try:
                adapter.close()
            except:
                pass

Here's how you use it:

with no_ssl_verification():
    requests.get('https://wrong.host.badssl.example/')
    print('It works')

    requests.get('https://wrong.host.badssl.example/', verify=True)
    print('Even if you try to force it to')

requests.get('https://wrong.host.badssl.example/', verify=False)
print('It resets back')

session = requests.Session()
session.verify = True

with no_ssl_verification():
    session.get('https://wrong.host.badssl.example/', verify=True)
    print('Works even here')

try:
    requests.get('https://wrong.host.badssl.example/')
except requests.exceptions.SSLError:
    print('It breaks')

try:
    session.get('https://wrong.host.badssl.example/')
except requests.exceptions.SSLError:
    print('It breaks here again')

Note that this code closes all open adapters that handled a patched request once you leave the context manager. This is because requests maintains a per-session connection pool and certificate validation happens only once per connection so unexpected things like this will happen:

>>> import requests
>>> session = requests.Session()
>>> session.get('https://wrong.host.badssl.example/', verify=False)
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
<Response [200]>
>>> session.get('https://wrong.host.badssl.example/', verify=True)
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
<Response [200]>
Answer from Blender on Stack Overflow
Top answer
1 of 15
923

From the documentation:

requests can also ignore verifying the SSL certificate if you set verify to False.

>>> requests.get('https://kennethreitz.com', verify=False)
<Response [200]>

If you're using a third-party module and want to disable the checks, here's a context manager that monkey patches requests and changes it so that verify=False is the default and suppresses the warning.

import warnings
import contextlib

import requests
from urllib3.exceptions import InsecureRequestWarning

old_merge_environment_settings = requests.Session.merge_environment_settings

@contextlib.contextmanager
def no_ssl_verification():
    opened_adapters = set()

    def merge_environment_settings(self, url, proxies, stream, verify, cert):
        # Verification happens only once per connection so we need to close
        # all the opened adapters once we're done. Otherwise, the effects of
        # verify=False persist beyond the end of this context manager.
        opened_adapters.add(self.get_adapter(url))

        settings = old_merge_environment_settings(self, url, proxies, stream, verify, cert)
        settings['verify'] = False

        return settings

    requests.Session.merge_environment_settings = merge_environment_settings

    try:
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', InsecureRequestWarning)
            yield
    finally:
        requests.Session.merge_environment_settings = old_merge_environment_settings

        for adapter in opened_adapters:
            try:
                adapter.close()
            except:
                pass

Here's how you use it:

with no_ssl_verification():
    requests.get('https://wrong.host.badssl.example/')
    print('It works')

    requests.get('https://wrong.host.badssl.example/', verify=True)
    print('Even if you try to force it to')

requests.get('https://wrong.host.badssl.example/', verify=False)
print('It resets back')

session = requests.Session()
session.verify = True

with no_ssl_verification():
    session.get('https://wrong.host.badssl.example/', verify=True)
    print('Works even here')

try:
    requests.get('https://wrong.host.badssl.example/')
except requests.exceptions.SSLError:
    print('It breaks')

try:
    session.get('https://wrong.host.badssl.example/')
except requests.exceptions.SSLError:
    print('It breaks here again')

Note that this code closes all open adapters that handled a patched request once you leave the context manager. This is because requests maintains a per-session connection pool and certificate validation happens only once per connection so unexpected things like this will happen:

>>> import requests
>>> session = requests.Session()
>>> session.get('https://wrong.host.badssl.example/', verify=False)
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
<Response [200]>
>>> session.get('https://wrong.host.badssl.example/', verify=True)
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
<Response [200]>
2 of 15
219

Use requests.packages.urllib3.disable_warnings() and verify=False on requests methods.

Note that you can either import urllib3 directly or import it from requests.packages.urllib3 to be sure to use the same version as the one in requests.

import requests

import urllib3
# or if this does not work with the previous import:
# from requests.packages import urllib3  

# Suppress only the single warning from urllib3.
urllib3.disable_warnings(category=urllib3.exceptions.InsecureRequestWarning)

# Set `verify=False` on `requests.post`.
requests.post(url='https://example.com', data={'bar':'baz'}, verify=False)

And if you want to suppress the warning from urllib3 only when used by the requests methods, you can use it in a context manager:

with urllib3.warnings.catch_warnings():
   urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

   requests.post(url='https://example.com', data={'bar':'baz'}, verify=False)
🌐
Requests
requests.readthedocs.io › en › latest › user › advanced
Advanced Usage — Requests 2.33.1 documentation
Setting verify to False may be useful during local development or testing. By default, verify is set to True. Option verify only applies to host certs. You can also specify a local cert to use as client side certificate, as a single file (containing the private key and the certificate) or as ...
🌐
GitHub
github.com › psf › requests › issues › 3829
Session.verify=False ignored when REQUESTS_CA_BUNDLE environment variable is set · Issue #3829 · psf/requests
January 24, 2017 - import os import requests os.environ['REQUESTS_CA_BUNDLE'] = 'asd.pem' # Must be an existing file r = requests.get('https://self-signed.badssl.com/', verify=False) print(r) # Prints: <Response [200]> session = requests.Session() session.verify = False r = session.get('https://self-signed.badssl.com/') print(r) # Fails: requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
Author   intgr
🌐
GitHub
github.com › psf › requests › issues › 2367
requests.post() issues a GET with verify=False on insecure ssl environment · Issue #2367 · psf/requests
December 3, 2014 - >>> resp = requests.Session().post(url, headers=self._headers, verify=False) >>> resp.content '{"code": 405, "total": null, "version": 1, "errors": [{"message": "Method \'GET\' not allowed."}]' On an HTTP environment, with the same call (including verify=False), I get the expected response.
Author   kevinlondon
🌐
GitHub
github.com › psf › requests › issues › 6669
Failed to ignore the SSL certificate verification when using `verify=False` option · Issue #6669 · psf/requests
March 23, 2024 - import requests session = requests.Session() session.verify = False session.get("https://website")
Author   urbanogilson
🌐
PISquare
pisquare.osisoft.com › s › question › 0D58W00007HOdwhSAD › secure-ways-to-avoid-ssl-local-issuer-certificate-issues-using-python-requests-and-pi-web-api
Secure ways to avoid SSL local issuer certificate issues using Python Requests and PI Web API. - Forum - PI Square - AVEVA Community
May 11, 2022 - pi_publish = requests.post( url=os.environ.get('PI_API_URL') + '/batch', json=batch_request, auth=HTTPBasicAuth(os.environ.get('PI_USERNAME'), os.environ.get('PI_PASSWORD')), verify=False )
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-disable-security-certificate-checks-for-requests-in-python
How to disable security certificate checks for requests in Python - GeeksforGeeks
October 29, 2022 - 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.
🌐
Finxter
blog.finxter.com › home › learn python blog › how to disable security certificate checks for requests in python
How to Disable Security Certificate Checks for Requests in Python - Be on the Right Side of Change
October 22, 2022 - Summary: You can disable security certificate checks for requests in Python in two ways: (i) Using Session.verify as False (ii) Setting verify = false inside the request method. Problem Statement: How to disable security certificate checks for ...
Top answer
1 of 1
12

Before coming to the different values for verify one needs to understand first, what this verify is about in the first place. It is about validating that the server certificate matches the expected one, which means that there is a direct end-to-end protected connection to the server and there is not some man in the middle who can read and modify the traffic. The server validation is (among other things) based on locally trust root certificates which represent trusted certificate authorities (CA): if no chain from the server provided leaf certificate to any of the local trust anchors can be constructed, then the certificate is not trusted. For more on this see SSL Certificate framework 101: How does the browser actually verify the validity of a given server certificate?.

verify=True then means that the server validation is done to use the default trust anchors, which are commonly the same public root certificates as used in the browser. verify=file.pem means to not use the default trust anchors but instead only the ones given in the specific file. This can be a single CA certificate, can be multiple CA certificates but can also be self-signed certificates expected for a specific server. Both of these options are usually sufficiently secure. But explicitly specifying which CA or certificate is trusted with verify=file.pem is more restrictive and thus more secure.

verify=False instead means that no certificate validation is done at all. This means a man in the middle will not be detected and thus anybody in the middle could sniff and fiddle with the traffic. This is totally unsafe and should never be used for critical data.. Critical data are obviously things like passwords or access tokens, but even exposing the exact URL visited can be considered critical in many cases.

🌐
GeeksforGeeks
geeksforgeeks.org › ssl-certificate-verification-python-requests
SSL Certificate Verification - Python requests - GeeksforGeeks
September 9, 2021 - # import requests module import requests # Making a get request response = requests.get('https://expired.badssl.com/', verify = False) # print request object print(response) ... Since output response 200 is printed, we can assume that request was successful. one can also pass the link to the certificate for validation via python requests only.
🌐
CodeQL
codeql.github.com › codeql-query-help › python › py-request-without-cert-validation
Request without certificate validation — CodeQL query help documentation
import requests #Unsafe requests requests.get('https://semmle.com', verify=False) # UNSAFE requests.get('https://semmle.com', verify=0) # UNSAFE #Various safe options requests.get('https://semmle.com', verify=True) # Explicitly safe requests.get('https://semmle.com', verify="/path/to/cert/") requests.get('https://semmle.com') # The default is to verify.
🌐
GitHub
github.com › Esri › workforce-scripts › issues › 14
Add option to set Requests verify=False and disable insecure connection warnings · Issue #14 · Esri/workforce-scripts
November 6, 2017 - import logging import sys import ...tLogger().debug("Posting to: {}".format(url)) # Added verify=False flag to prevent issues with SSL Verification errors response = requests.post(url, data, files=files, ver...
Author   jmdye
🌐
techtutorialsx
techtutorialsx.wordpress.com › 2020 › 04 › 15 › python-requests-disabling-ssl-validation
Python Requests: Disable SSL validation – techtutorialsx
May 11, 2021 - import requests response = requests.request("GET", "https://self-signed.badssl.com/", verify = False) print(response.text) For comparison, we will also do the same request without skipping the SSL validation (when not specified, the parameter verify is set to True). import requests response = requests.request("GET", "https://self-signed.badssl.com/") print(response.text) To test the previous code, we will start by running the example where we keep the SSL validation. I’ll be using IDLE, a Python IDE.
🌐
TutorialsPoint
tutorialspoint.com › requests › requests_ssl_certification.htm
Requests - SSL Certification
import requests getdata = requests.get('https://jsonplaceholder.typicode.com/users', verify=False) print(getdata.text) You will get the output, but it will also give a warning message that, the SSL certificate is not verified and adding certificate verification is advised. E:\prequests>python makeRequest.py connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made.
🌐
GitHub
github.com › dell › PyU4V › issues › 125
Setting verify to False not ignore the SSL · Issue #125 · dell/PyU4V
April 21, 2021 - conn = U4VConn( username=username, password=password, server_ip=address, port='8443', verify=False, array_id=array_id) conn.common.get_uni_version() The GET request to URL https://X.X.X.X:8443/univmax/restapi/84/system/version timed-out, but may have been successful.
Author   lafada
🌐
w3resource
w3resource.com › python-exercises › requests › python-request-exercise-9.php
Python: Verify SSL certificates for HTTPS requests - w3resource
August 11, 2025 - Write a Python program to verify the SSL certificate for a website that is certified. ... import requests #Requests ignore verifying the SSL certificate if you set verify to False # Making a get request response = requests.get('https://rigaux.org/', verify=False) print(response) print("\n=======================================================\n") #Requests verifies SSL certificates for HTTPS requests, just like a web browser.