Skip to content

Commit db34745

Browse files
authored
Merge pull request #154 from keithbowes/extra-search-paths
Find extra paths for default CA bundle through the SSL module if possible (Python 3.4+)
2 parents 07c186e + 974c31d commit db34745

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

offlineimap/utils/distro_utils.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,25 @@ def get_os_sslcertfile_searchpath():
7272
at all.
7373
"""
7474
os_name = get_os_name()
75-
location = __DEF_OS_LOCATIONS.get(os_name, None)
75+
location = __DEF_OS_LOCATIONS.get(os_name, [])
76+
77+
try:
78+
import ssl
79+
verify_paths = ssl.get_default_verify_paths()
80+
cafile_by_envvar = os.getenv(verify_paths.openssl_cafile_env)
81+
if cafile_by_envvar is not None:
82+
location += [cafile_by_envvar]
83+
cafile_resolved = verify_paths.cafile
84+
if cafile_resolved is not None:
85+
location += [cafile_resolved]
86+
cafile_hardcoded = verify_paths.openssl_cafile
87+
if cafile_hardcoded is not None:
88+
location += [cafile_hardcoded]
89+
except AttributeError:
90+
pass
91+
finally:
92+
if len(location) == 0:
93+
return None
7694

7795
return location
7896

0 commit comments

Comments
 (0)