Ignore certificate validation with urllib3
Try following code:
import urllib3c = urllib3.HTTPSConnectionPool('10.0.3.168', port=9001, cert_reqs='CERT_NONE', assert_hostname=False)c.request('GET', '/')
See Setting assert_hostname to False will disable SSL hostname verification
In this question I see many answers but, IMHO, too much unnecessary information that can lead to confusion.
Just add the cert_reqs='CERT_NONE'
parameter
import urllib3http = urllib3.PoolManager(cert_reqs='CERT_NONE')
I found the answer to my problem. The urllib3 documentation does not, in fact, completely explain how to suppress SSL certificate validation. What is missing is a reference to ssl.CERT_NONE.
My code has a boolean, ssl_verify, to indicate whether or not I want SSL validation. The code now looks like this:
import sslimport urllib3### if (ssl_verify): cert_reqs = ssl.CERT_REQUIRED else: cert_reqs = ssl.CERT_NONE urllib3.disable_warnings() http = urllib3.PoolManager(cert_reqs = cert_reqs) auth_url = f'https://{fmc_ip}/api/fmc_platform/v1/auth/generatetoken' type = {'Content-Type': 'application/json'} auth = urllib3.make_headers(basic_auth=f'{username}:{password}') headers = { **type, **auth } resp = http.request('POST', auth_url, headers=headers, timeout=10.0)