simplify auto-disabling certificate verification
if no certificate bundle is found
This commit is contained in:
parent
09d872a2b1
commit
4ca4631bad
@ -389,18 +389,13 @@ http.cookiejar.MozillaCookieJar.magic_re = re.compile(
|
|||||||
# The first import of requests happens inside this file.
|
# The first import of requests happens inside this file.
|
||||||
# If we are running on Windows and the from requests expected certificate file
|
# If we are running on Windows and the from requests expected certificate file
|
||||||
# is missing (which happens in a standalone executable from py2exe), the
|
# is missing (which happens in a standalone executable from py2exe), the
|
||||||
# requests.Session object gets monkey patched to always set its 'verify'
|
# 'verify' option is globally set to False to avoid an exception being thrown
|
||||||
# attribute to False to avoid an exception being thrown when attempting to
|
# when attempting to access https:// URLs.
|
||||||
# access https:// URLs.
|
|
||||||
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
import os.path
|
import os.path
|
||||||
import requests.certs
|
import requests.certs
|
||||||
import requests.packages.urllib3 as ulib3
|
import requests.packages.urllib3 as ulib3
|
||||||
if not os.path.isfile(requests.certs.where()):
|
if not os.path.isfile(requests.certs.where()):
|
||||||
def patched_init(self):
|
config.set(("verify",), False)
|
||||||
session_init(self)
|
|
||||||
self.verify = False
|
|
||||||
session_init = requests.Session.__init__
|
|
||||||
requests.Session.__init__ = patched_init
|
|
||||||
ulib3.disable_warnings(ulib3.exceptions.InsecureRequestWarning)
|
ulib3.disable_warnings(ulib3.exceptions.InsecureRequestWarning)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user