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)
🌐
ScrapingAnt
scrapingant.com › blog › requests-ignore-ssl
How to Ignore SSL Certificate in Python Requests Library | ScrapingAnt
August 16, 2024 - One of the simplest methods to ignore SSL certificate errors in Python's requests library is to disable SSL verification globally. This can be achieved by setting the verify parameter to False when making requests.
Discussions

Python requests whit SSL verification deactivated
My question is about the security implications of this. Am I under any security risks if I'm just getting something (and not sending anything) from a website and not checking the TLS certificate? By telling the Python library to ignore SSL certificate verification, you are essentially accepting any SSL certificate the website may present, which can be invalid, self-signed, or expired. Unless you know the website and the actual cause of the SSL certificate validation failure, I would not trust anything you get from that website. The only time I'd disable verification is when the certificate has expired recently, which can happen even to legitimate websites where the admins have neglected to renew the certs. Other than that, I would not trust anything. What this means is, if you are under a MitM attack, you may think you are communicating with example.com, but you are actually talking to evil.com pretending to be example.com, and you have disabled the one mechanism that helps you know the difference. More on reddit.com
🌐 r/privacy
1
0
November 27, 2024
How can I disable SSL verification, when using OpenAi API in python?
Due to my network env., I have no choice but to set “SSL verification” disabled. I could set it in python when using “requests” for any other API, -requests.post(…, verify=False) -requests.get(…, verify=False). But how could I make SSL verification disabled when I use ... More on community.openai.com
🌐 community.openai.com
8
1
March 21, 2023
SSL Verify in other modules that use requests (not using requests myself)
https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests More on reddit.com
🌐 r/learnpython
1
0
May 31, 2023
CURL_CA_BUNDLE= disables certificate verification
I'm not the first to notice this, see: https://stackoverflow.com/questions/48391750/disable-python-requests-ssl-validation-for-an-imported-module Which implies people have even relied on the current behavior as a hack ... but I think it'... More on github.com
🌐 github.com
24
February 23, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-disable-security-certificate-checks-for-requests-in-python
How to disable security certificate checks for requests in Python - GeeksforGeeks
July 23, 2025 - Explanation: By passing verify=False to the request method we disabled the security certificate check and made the program error-free to execute. But this approach will throw warnings as shown in the output picture.
🌐
ProxiesAPI
proxiesapi.com › articles › expert-techniques-for-disabling-ssl-certificate-verification-in-python-requests
Expert Techniques for Disabling SSL Certificate Verification in Python Requests | ProxiesAPI
Use per-request disabling over global where possible. Suppress warnings only temporarily during testing. Rotate custom certs periodically if using them. Validate custom certs come from expected CAs. Only send non-sensitive data when verification is off. Following these tips will keep you secure even as you temporarily work around SSL issues. Let's round out this guide by looking at a few other things to keep in mind: Python version - The methods may differ slightly between Python 2 and 3.
🌐
Reddit
reddit.com › r/privacy › python requests whit ssl verification deactivated
r/privacy on Reddit: Python requests whit SSL verification deactivated
November 27, 2024 -

Hello! I'm accessing some html on a public website through python script using the requests library. I got an error and found out that a way to solve it was by not checking the server's TLS certificate. On python's requests library you do this by setting the verify parameter to False:

html = requests.get(url=my_url, verify=False).text

My question is about the security implications of this. Am I under any security risks if I'm just getting something (and not sending anything) from a website and not checking the TLS certificate? I do not understand TLS encryption so any help would be welcomed, thanks!

🌐
HayaGeek
hayageek.com › home › disable ssl verification in python – requests, urllib3
Disable SSL Verification in Python - requests, urllib3
February 7, 2024 - Alternatively, you can set REQUESTS_CA_BUNDLE environment variable to an empty string or to a non-existent file will effectively disable SSL verification.
🌐
ScrapingBee
scrapingbee.com › webscraping-questions › requests › how-to-fix-ssl-error-in-python-requests
How to fix SSLError in Python requests? | ScrapingBee
The easiest way to fix this issue is to disable SSL verification for that particular web address by passing in verify=False as an argument to the method calls. Just make sure you are not sending any ...
Find elsewhere
🌐
Python Requests
python-requests.org › home › news › python requests ignore ssl: a comprehensive guide
Python Requests Ignore SSL: A Comprehensive Guide -
November 13, 2025 - Python requests provides a straightforward way to bypass SSL verification using the verify parameter.
🌐
Reddit
reddit.com › r/learnpython › ssl verify in other modules that use requests (not using requests myself)
r/learnpython on Reddit: SSL Verify in other modules that use requests (not using requests myself)
May 31, 2023 -

Hello,
I'm trying to set up python on a Windows computer to run some scripts to migrate from an old PBX server. We have our own internal PKI and the certs are in the wincertstore. The pbx uses our certs (although for the API, it might use it's own signed cert). Either way, since it's going away, I don't really want to fix certs on it. I'd rather have python ignore these errors just to get through an intern being able to use it to pull some data, migrate users, and be done with this thing.
I'm using the ciscoaxl module which in turn relies on requests. I've read a ton of posts about how to ignore SSL certs when using requests, but how can I do that when it's just another module calling (ciscoaxl) calling requets? I think my best bet is an environment variable but I cannot find one other than to point it at a CA bundle (and not totally clear how to make that in windows).
Either way, is there a way I can pass verify=False in to the ciscoaxl module for requests to then ignore it? Is there an env var I can set to do it globally? Or do I basically need to pull the module's source and update the code for my own use?

🌐
ScrapeOps
scrapeops.io › home › python web scraping playbook › python requests fix ssl error
Fix SSL Errors in Python Requests | ScrapeOps
May 5, 2024 - The shortest, easiest, and most effective solution to fix SSL errors in Python requests is to disable SSL verification.
🌐
GitHub
github.com › psf › requests › issues › 6071
CURL_CA_BUNDLE= disables certificate verification · Issue #6071 · psf/requests
February 23, 2022 - CURL_CA_BUNDLE= disables certificate verification#6071 · #6074 · Copy link · owtaylor · opened · on Feb 23, 2022 · Issue body actions · I'm not the first to notice this, see: https://stackoverflow.com/questions/48391750/disable-python-requests-ssl-validation-for-an-imported-module ·
Author   owtaylor
🌐
DEV Community
dev.to › toby-patrick › how-to-fix-ssl-certificateverifyfailed-in-python-requests-35nl
How to Fix “SSL: CERTIFICATE_VERIFY_FAILED” in Python Requests - DEV Community
September 15, 2025 - If you’re in a local environment and need a quick workaround for testing, you can disable certificate verification. For example, to bypass certificate validation entirely, you can use the ignore SSL option with curl (e.g., curl --insecure ...
🌐
ProxiesAPI
proxiesapi.com › articles › making-http-requests-in-python-without-ssl-verification
Making HTTP Requests in Python Without SSL Verification | ProxiesAPI
import ssl import requests context = ssl.create_default_context() context.check_hostname = False context.verify_mode = ssl.CERT_NONE response = requests.get("https://example.com", ssl_context=context) You can also suppress the SSL warnings if you just want to ignore them: ... import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) response = requests.get("https://example.com")
🌐
techtutorialsx
techtutorialsx.wordpress.com › 2020 › 04 › 15 › python-requests-disabling-ssl-validation
Python Requests: Disable SSL validation – techtutorialsx
May 11, 2021 - As first input we will pass a string with the HTTP method (“GET”) and as second input the endpoint to which we want to send the request. Then we will pass an optional parameter called verify with the value False. This will allow to skip ...
🌐
Delft Stack
delftstack.com › home › howto › python › python requests ignore ssl
How to Ignore SSL Security Certificate Check in Python Requests | Delft Stack
February 2, 2024 - This program turns off the SSL certificate verification using verify=False to disable the security certificate check using requests.
🌐
GitHub
gist.github.com › random-robbie › bb65335b9632bf1ed38923c768cefa02
Python Requests Ignore Bad SSL certificate · GitHub
Python Requests Ignore Bad SSL certificate. GitHub Gist: instantly share code, notes, and snippets.
Top answer
1 of 3
3

The correct answer here is "it depends".

You've given us very little information to go on, so I'm going to make some assumptions and list them below (if any of them do not match, then you should reconsider your choice):

  1. You are constantly connecting to the same website in your CRON job
  2. You know the website fairly well and are certain that the certificate-related errors are benign
  3. You are not sending sensitive data to the website in order to scrape it (such as login and user name)

If that is the situation (which I am guessing it is) then it should be generally harmless. That said, whether or not it is "safe" depends on your definition of that word in the context of two computers talking to each other over the internet.

As others have said, Requests does not attempt to render HTML, parse XML, or execute JavaScript. Because it simply is retrieving your data, then the biggest risk you run is not receiving data that can be verified came from the server you thought it was coming from. If, however, you're using requests in combination with something that does the above, there are a myriad of potential attacks that a malicious man in the middle could use against you.

There are also options that mean you don't have to forgo verification. For example, if the server uses a self-signed certificate, you could get the certificate in PEM format, save it to a file and provide the path to that file to the verify argument instead. Requests would then be able to validate the certificate for you.

So, as I said, it depends.


Update based on Albert's replies

So what appears to be happening is that the website in question sends only the leaf certificate which is valid. This website is relying on browser behaviour that currently works like so:

The browser connects to the website and notes that the site does not send it's full certificate chain. It then goes and retrieves the intermediaries, validates them, and completes the connection. Requests, however, uses OpenSSL for validation and OpenSSL does not contain any such behaviour. Since the validation logic is almost entirely in OpenSSL, Requests has no way to emulate a browser in this case.

Further, Security tooling (e.g., SSLLabs) has started counting this configuration against a website's security ranking. It's increasingly the opinion that websites should send the entire chain. If you encounter a website that doesn't, contacting them and informing them of that is the best course forward.

If the website refuses to update their certificate chain, then Requests' users can retrieve the PEM encoded intermediary certificates and stick them in a .pem file which they then provide to the verify parameter. Requests presently only includes Root certificates in its trust store (as every browser does). It will never ship intermediary certificates because there are just too many. So including the intermediaries in a bundle with the root certificate(s) will allow you to verify the website's certificate. OpenSSL will have a PEM encoded file that has each link in the chain and will be able to verify up to the root certificate.

2 of 3
2

This is probably one more appropriate on https://security.stackexchange.com/.

Effectively it makes it only slightly better than using HTTP instead of HTTPS. So almost all (apart from without the server's certificate someone would have to actively do something) of the risks of HTTP would apply.

Basically it would be possible to see both the sent and received data by a Man in The Middle attack.. or even if that site had ever been compromised and the certificate was stolen from them. If you are storing cookies for that site, those cookies will be revealed (i.e. if facebook.com then a session token could be stolen) if you are logging in with a username and password then that could be stolen too.

What do you do with that data once you retrieve it? Are you downloading any executable code? Are you downloading something (images you store on a web-server?) that a skilled attacker (even by doing something like modifying your DNS settings on your router) could force you to download a file ("news.php") and store on your web-server that could become executable (a .php script instead of a web-page)?

🌐
GeeksforGeeks
geeksforgeeks.org › python › ssl-certificate-verification-python-requests
SSL Certificate Verification - Python requests - GeeksforGeeks
July 12, 2025 - Let us try to access a website ... raises this error. To disable certificate verification, at the client side, one can use verify attribute....
🌐
Pythonrequests
pythonrequests.com › python-requests-disable-ssl-verification
python requests disable ssl verification
July 12, 2023 - The easiest and quickest way to disable SSL verification is by disabling it globally in your Python Requests session.