Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

python3 urllib3: ignore certificates

In python3 urrlib3, when you set up a pool manager, you can tell it to use your ca cert bundle, or even just ignore certs.

import urrlib3
webpool = urllib3.PoolManager(cert_reqs="CERT_NONE")
webpool = urllib3.PoolManager(cert_reqs="CERT_REQUIRED",ca_certs="/path/to/cacerts.pem")

You can change the settings later too (but I haven't actually tested this yet!):

webpool.connection_pool_kw["cert_reqs"] = "CERT_NONE"

If you use certifi:

import certifi, urllib3
webpool = urllib3.PoolManager(ca_certs=certifi.where())

And also to suppress the warnings (HERE BE DRAGONS):

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Use at my own risk.

Comments