Merge pull request #17 from thekix/master

Use system sslcacertfile by default
This commit is contained in:
Rodolfo García Peñas (kix) 2020-10-27 07:52:34 +01:00 committed by GitHub
commit df16bd595d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,13 +233,15 @@ class IMAPRepository(BaseRepository):
def getsslcacertfile(self): def getsslcacertfile(self):
"""Determines CA bundle. """Determines CA bundle.
Returns path to the CA bundle. It is either explicitely specified Returns path to the CA bundle. It is explicitely specified or
or requested via "OS-DEFAULT" value (and we will search known requested via "OS-DEFAULT" value (and we will search known
locations for the current OS and distribution). locations for the current OS and distribution). If it is not
specified, we will search it in the known locations.
If search via "OS-DEFAULT" route yields nothing, we will throw an If search route, via "OS-DEFAULT" or because is not specified,
exception to make our callers distinguish between not specified yields nothing, we will throw an exception to make our callers
value and non-existent default CA bundle. distinguish between not specified value and non-existent
default CA bundle.
It is also an error to specify non-existent file via configuration: It is also an error to specify non-existent file via configuration:
it will error out later, but, perhaps, with less verbose explanation, it will error out later, but, perhaps, with less verbose explanation,
@ -250,7 +252,10 @@ class IMAPRepository(BaseRepository):
xforms = [os.path.expanduser, os.path.expandvars, os.path.abspath] xforms = [os.path.expanduser, os.path.expandvars, os.path.abspath]
cacertfile = self.getconf_xform('sslcacertfile', xforms, None) cacertfile = self.getconf_xform('sslcacertfile', xforms, None)
# Can't use above cacertfile because of abspath. # Can't use above cacertfile because of abspath.
if self.getconf('sslcacertfile', None) == "OS-DEFAULT": conf_sslacertfile = self.getconf('sslcacertfile', None)
if conf_sslacertfile == "OS-DEFAULT" or \
conf_sslacertfile == None or \
conf_sslacertfile == '':
cacertfile = get_os_sslcertfile() cacertfile = get_os_sslcertfile()
if cacertfile is None: if cacertfile is None:
searchpath = get_os_sslcertfile_searchpath() searchpath = get_os_sslcertfile_searchpath()