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
(self)
| 236 | return self.getconf_xform('sslclientkey', xforms, None) |
| 237 | |
| 238 | def getsslcacertfile(self): |
| 239 | """Determines CA bundle. |
| 240 | |
| 241 | Returns path to the CA bundle. It is either explicitely specified |
| 242 | or requested via "OS-DEFAULT" value (and we will search known |
| 243 | locations for the current OS and distribution). |
| 244 | |
| 245 | If search via "OS-DEFAULT" route yields nothing, we will throw an |
| 246 | exception to make our callers distinguish between not specified |
| 247 | value and non-existent default CA bundle. |
| 248 | |
| 249 | It is also an error to specify non-existent file via configuration: |
| 250 | it will error out later, but, perhaps, with less verbose explanation, |
| 251 | so we will also throw an exception. It is consistent with |
| 252 | the above behaviour, so any explicitely-requested configuration |
| 253 | that doesn't result in an existing file will give an exception. |
| 254 | """ |
| 255 | |
| 256 | xforms = [os.path.expanduser, os.path.expandvars, os.path.abspath] |
| 257 | cacertfile = self.getconf_xform('sslcacertfile', xforms, None) |
| 258 | # Can't use above cacertfile because of abspath. |
| 259 | if self.getconf('sslcacertfile', None) == "OS-DEFAULT": |
| 260 | cacertfile = get_os_sslcertfile() |
| 261 | if cacertfile == None: |
| 262 | searchpath = get_os_sslcertfile_searchpath() |
| 263 | if searchpath: |
| 264 | reason = "Default CA bundle was requested, "\ |
| 265 | "but no existing locations available. "\ |
| 266 | "Tried %s." % (", ".join(searchpath)) |
| 267 | else: |
| 268 | reason = "Default CA bundle was requested, "\ |
| 269 | "but OfflineIMAP doesn't know any for your "\ |
| 270 | "current operating system." |
| 271 | raise OfflineImapError(reason, OfflineImapError.ERROR.REPO) |
| 272 | if cacertfile is None: |
| 273 | return None |
| 274 | if not os.path.isfile(cacertfile): |
| 275 | reason = "CA certfile for repository '%s' couldn't be found. "\ |
| 276 | "No such file: '%s'" % (self.name, cacertfile) |
| 277 | raise OfflineImapError(reason, OfflineImapError.ERROR.REPO) |
| 278 | return cacertfile |
| 279 | |
| 280 | def gettlslevel(self): |
| 281 | return self.getconf('tls_level', 'tls_compat') |
no test coverage detected