File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858}
5959
6060
61- def fix_tls_cert_store ():
61+ def fix_tls_cert_store (cafile_path ):
6262 """
6363 Ensure we are using the system certstore by default
6464
6565 See https://github.com/psf/requests/issues/2966
6666 Inspired by https://github.com/psf/requests/issues/2966#issuecomment-614323746
6767 """
6868
69- try :
70- system_ca_store = ssl .get_default_verify_paths ().cafile
71- if os .stat (system_ca_store ).st_size > 0 :
72- requests .utils .DEFAULT_CA_BUNDLE_PATH = system_ca_store
73- requests .adapters .DEFAULT_CA_BUNDLE_PATH = system_ca_store
74- except :
75- pass
69+ # Check if we got a CA file path
70+ if not cafile_path :
71+ return
72+
73+ # If CA file contains something, set as default
74+ if os .stat (cafile_path ).st_size > 0 :
75+ requests .utils .DEFAULT_CA_BUNDLE_PATH = cafile_path
76+ requests .adapters .DEFAULT_CA_BUNDLE_PATH = cafile_path
7677
7778
7879class CriticalException (Exception ):
@@ -406,7 +407,7 @@ def commandline(args):
406407
407408
408409def main (args ):
409- fix_tls_cert_store ()
410+ fix_tls_cert_store (ssl . get_default_verify_paths (). cafile )
410411
411412 if args .insecure :
412413 urllib3 .disable_warnings ()
You can’t perform that action at this time.
0 commit comments