Exemple #1
0
 def getsslcacertfile(self):
     """Return the absolute path of the CA certfile to use, if any"""
     cacertfile = self.getconf('sslcacertfile', get_os_sslcertfile())
     if cacertfile is None:
         return None
     cacertfile = os.path.expanduser(cacertfile)
     cacertfile = os.path.abspath(cacertfile)
     if not os.path.isfile(cacertfile):
         raise SyntaxWarning("CA certfile for repository '%s' could "
                             "not be found. No such file: '%s'" \
                             % (self.name, cacertfile))
     return cacertfile
Exemple #2
0
 def getsslcacertfile(self):
     """Return the absolute path of the CA certfile to use, if any"""
     cacertfile = self.getconf('sslcacertfile', get_os_sslcertfile())
     if cacertfile is None:
         return None
     cacertfile = os.path.expanduser(cacertfile)
     cacertfile = os.path.abspath(cacertfile)
     if not os.path.isfile(cacertfile):
         raise SyntaxWarning("CA certfile for repository '%s' could "
                             "not be found. No such file: '%s'" \
                             % (self.name, cacertfile))
     return cacertfile
Exemple #3
0
    def getsslcacertfile(self):
        """Determines CA bundle.

        Returns path to the CA bundle.  It is either explicitely specified
        or requested via "OS-DEFAULT" value (and we will search known
        locations for the current OS and distribution).

        If search via "OS-DEFAULT" route yields nothing, we will throw an
        exception to make our callers distinguish between not specified
        value and non-existent default CA bundle.

        It is also an error to specify non-existent file via configuration:
        it will error out later, but, perhaps, with less verbose explanation,
        so we will also throw an exception.  It is consistent with
        the above behaviour, so any explicitely-requested configuration
        that doesn't result in an existing file will give an exception.
        """

        xforms = [os.path.expanduser, os.path.expandvars, os.path.abspath]
        cacertfile = self.getconf_xform("sslcacertfile", xforms, None)
        # Can't use above cacertfile because of abspath.
        if self.getconf("sslcacertfile", None) == "OS-DEFAULT":
            cacertfile = get_os_sslcertfile()
            if cacertfile == None:
                searchpath = get_os_sslcertfile_searchpath()
                if searchpath:
                    reason = (
                        "Default CA bundle was requested, "
                        "but no existing locations available.  "
                        "Tried %s." % (", ".join(searchpath))
                    )
                else:
                    reason = (
                        "Default CA bundle was requested, "
                        "but OfflineIMAP doesn't know any for your "
                        "current operating system."
                    )
                raise OfflineImapError(reason, OfflineImapError.ERROR.REPO)
        if cacertfile is None:
            return None
        if not os.path.isfile(cacertfile):
            reason = "CA certfile for repository '%s' couldn't be found.  " "No such file: '%s'" % (
                self.name,
                cacertfile,
            )
            raise OfflineImapError(reason, OfflineImapError.ERROR.REPO)
        return cacertfile
Exemple #4
0
    def getsslcacertfile(self):
        """Determines CA bundle.

        Returns path to the CA bundle.  It is either explicitely specified
        or requested via "OS-DEFAULT" value (and we will search known
        locations for the current OS and distribution).

        If search via "OS-DEFAULT" route yields nothing, we will throw an
        exception to make our callers distinguish between not specified
        value and non-existent default CA bundle.

        It is also an error to specify non-existent file via configuration:
        it will error out later, but, perhaps, with less verbose explanation,
        so we will also throw an exception.  It is consistent with
        the above behaviour, so any explicitely-requested configuration
        that doesn't result in an existing file will give an exception.
        """

        xforms = [os.path.expanduser, os.path.expandvars, os.path.abspath]
        cacertfile = self.getconf_xform('sslcacertfile', xforms, None)
        # Can't use above cacertfile because of abspath.
        if self.getconf('sslcacertfile', None) == "OS-DEFAULT":
            cacertfile = get_os_sslcertfile()
            if cacertfile == None:
                searchpath = get_os_sslcertfile_searchpath()
                if searchpath:
                    reason = "Default CA bundle was requested, "\
                             "but no existing locations available.  "\
                             "Tried %s." % (", ".join(searchpath))
                else:
                    reason = "Default CA bundle was requested, "\
                             "but OfflineIMAP doesn't know any for your "\
                             "current operating system."
                raise OfflineImapError(reason, OfflineImapError.ERROR.REPO)
        if cacertfile is None:
            return None
        if not os.path.isfile(cacertfile):
            reason = "CA certfile for repository '%s' couldn't be found.  "\
                     "No such file: '%s'" % (self.name, cacertfile)
            raise OfflineImapError(reason, OfflineImapError.ERROR.REPO)
        return cacertfile