I had the same issue. Looks like OpenAI thought about a way to solve this, so added the property “verify_ssl_certs”, which is True buy default. In theory that could be disabled with the following line: openai.verify_ssl_certs = False However, as per the observation by lpels at (link removed), t… Answer from thecowster on community.openai.com
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)
Discussions

How to disable SSL certificate verification in Python?
I have read the docs up and down and I can't seem to find a reference for disabling SSL certificate verification. As of right now, I currently have a project where I am doing an intentional man-in-... More on github.com
🌐 github.com
51
June 29, 2019
Add CLI option to disable the security certificate check in Python requests
safety version: 1.9.0 Python version: Python 3.8.2 Operating System: Windows 10 Description I have proxy server which breaks ssl sertificates. So I can't get database though fetch_database_url(). n... More on github.com
🌐 github.com
3
May 8, 2020
Can I turn off ssl verification on pip?
In some situations where pip cannot establish an HTTPS connection, one alternative is to download the WHL file from the pip repository using your web browser. Make sure the pip repository is legit first though as there is some spam sites out there hoping you will pull from them so they can embed randomware. Download the WHL files over HTTPS with SSL Verification and place them all in a "whl" folder. Then reference them like in the command below... Use the following: pip install --no-index --find-links file:///home/user123/Downloads/whl --trusted-host file:///home/user123/Downloads/whl MyLibraryName More on reddit.com
🌐 r/learnpython
3
1
July 14, 2021
Disable Python requests SSL validation for an imported module - Stack Overflow
I'm running a Python script that uses the requests package for making web requests. However, the web requests go through a proxy with a self-signed cert. As such, requests raise the following Excep... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › ccxt › ccxt › issues › 5394
How to disable SSL certificate verification in Python? · Issue #5394 · ccxt/ccxt
June 29, 2019 - (Caused by SSLError(SSLCertVerificationError("hostname 'pro.coinbase.com' doesn't match 'Felipes-MacBook-Pro.local'"))) Which is also warranted, but a check I would much rather disable. Any help would be appreciated. My idea would be something simple as: ex = getattr(ccxt, exchange)( { "session": cfscrape.create_scraper(), "enableRateLimit": False, "verify_ssl_certificates": False, } )
Author   synchronizing
🌐
techtutorialsx
techtutorialsx.wordpress.com › 2020 › 04 › 15 › python-requests-disabling-ssl-validation
Python Requests: Disable SSL validation – techtutorialsx
May 11, 2021 - If you don’t have the requests library installed yet, it can be easily done using pip, just by sending the following command: ... This tutorial was tested on Python 3.7.2 with version 2.23.0 of the Requests library. We will start by importing the requests module. ... Then, to do the request, we simply need to call the request method. 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.
🌐
HayaGeek
hayageek.com › home › disable ssl verification in python – requests, urllib3
Disable SSL Verification in Python - requests, urllib3
February 7, 2024 - Learn to disable SSL verification in Python with practical code examples for http.client, requests, urllib3, and aiohttp packages.
Find elsewhere
🌐
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 - We can disable the security certificate checks for requests in Python by setting the Session.verify to False. Simply declare Session.verify = False instead of passing verify = True.
🌐
GitHub
github.com › pyupio › safety › issues › 302
Add CLI option to disable the security certificate check in Python requests · Issue #302 · pyupio/safety
May 8, 2020 - So I can't get database though fetch_database_url(). now I manualy change line: r = requests.get(url=url, timeout=REQUEST_TIMEOUT, headers=headers, proxies=proxy) to · r = requests.get(url=url, timeout=REQUEST_TIMEOUT, headers=headers, proxies=proxy, verify=False) Can you add cli option to ignore SSL certficate like https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests ·
Author   Zoynels
🌐
Seanlaw
seanlaw.github.io › 2019 › 12 › 03 › ignoring-requests-ssl-in-third-party-apps
Ignoring Requests SSL Verification in Third Party Apps
December 3, 2019 - Luckily, you can turn this off ... class, set ... Alternatively, directly from the command line, you might be able to tell the ssl Python module to temporarily disable SSL verification ......
🌐
Cloudera Community
community.cloudera.com › t5 › Support-Questions › How-i-can-ignore-ssl-certification-on-python › m-p › 384055
Re: How i can ignore ssl certification on python? - Cloudera Community - 330275
July 21, 2025 - https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-pyth... ... Hello, @mananasaly, the SSL certificate error in Python you are getting can occur due to when making HTTPS requests using the requests module in Python. To solve the error, I found the reference guide from:- https://cheapsslweb.com/blog/ssl-certificate-verify-failed-error-in-python/. You can refer to it, maybe it will be helpful to solve the error.
🌐
ReqBin
reqbin.com › req › python › c-ug1qqqwh › curl-ignore-certificate-checks
Python | How to ignore invalid and self-signed SSL certificate errors in Curl?
December 5, 2023 - To ignore invalid and self-signed certificate checks on Curl, use the -k or --insecure command-line option. This option allows Curl to perform "insecure" SSL connections and skip SSL certificate checks while you still have SSL-encrypted ...
🌐
Reviewboard
reviews.reviewboard.org › r › 7275
Add a --disable-ssl-verification flag for use with Python 2.7.9+ | Review Request | Review Board
May 1, 2015 - Python now verifies SSL certificates and their associated hostnames by default, which is fantastic. However, it makes things a bit of a pain for users who have put a self-signed SSL certificate on their Review Board server. This change adds a command-line flag and config variable for disabling certificate verification.
🌐
Conda
docs.conda.io › projects › conda › en › stable › user-guide › configuration › disable-ssl-verification.html
Disabling SSL verification — conda 26.3.2 documentation
In addition to disabling SSL via environment variables, you can disable it by setting ssl_verify to false in your config files. To do so, run the following commands to disable and enable it:
Top answer
1 of 3
57

Note: This solution is a complete hack. And works only for requests < 2.28 (https://github.com/psf/requests/pull/6074)

Short answer: Set the CURL_CA_BUNDLE environment variable to an empty string.

Before:

$ python
import requests
requests.get('http://www.google.com')
<Response [200]>

requests.get('https://www.google.com')
...
File "/usr/local/lib/python2.7/site-packages/requests-2.17.3-py2.7.egg/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)",)

After:

$ CURL_CA_BUNDLE="" python
import requests
requests.get('http://www.google.com')
<Response [200]>

requests.get('https://www.google.com')
/usr/local/lib/python2.7/site-packages/urllib3-1.21.1-py2.7.egg/urllib3/connectionpool.py:852: 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]>

How it works

This solution works because Python requests overwrites the default value for verify from the environment variables CURL_CA_BUNDLE and REQUESTS_CA_BUNDLE, as can be seen here:

if verify is True or verify is None:
verify = (os.environ.get('REQUESTS_CA_BUNDLE') or
    os.environ.get('CURL_CA_BUNDLE'))

The environment variables are meant to specify the path to the certificate file or CA_BUNDLE and are copied into verify. However, by setting CURL_CA_BUNDLE to an empty string, the empty string is copied into verify and in Python, an empty string evaluates to False.

Note that this hack only works with the CURL_CA_BUNDLE environment variable - it does not work with the REQUESTS_CA_BUNDLE. This is because verify is set with the following statement:

verify = (os.environ.get('REQUESTS_CA_BUNDLE') or os.environ.get('CURL_CA_BUNDLE'))

It only works with CURL_CA_BUNDLE because '' or None is not the same as None or '', as can be seen below:

print repr(None or "")
# Prints: ''
print repr("" or None )
# Prints: None
2 of 3
4

I saw this hack only due to some trouble with my private CA.

The given hack with CURL_CA_BUNDLE='' will not longer work in 2022 with next minor release of requests (that means 2.28 ?).

Please refer to GH issue 6071 which was fixed 6 days before in Feb. 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.
🌐
Splunk Community
community.splunk.com › t5 › All-Apps-and-Add-ons › How-to-disable-verify-SSL-cert › m-p › 647788
Solved: Re: Disable verify SSL cert - Splunk Community
June 22, 2023 - this also works for ta-webtools. /opt/splunk/etc/apps/TA-webtools/bin/curl.py sed -E 's/verify=True/verify=False/'
🌐
GitHub
github.com › psf › requests › issues › 6071
CURL_CA_BUNDLE= disables certificate verification · Issue #6071 · psf/requests
February 23, 2022 - 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'...
Author   owtaylor