| 1303 | |
| 1304 | |
| 1305 | def __init__(self, host='', port=IMAP4_SSL_PORT, keyfile=None, |
| 1306 | certfile=None, ssl_context=None, timeout=None): |
| 1307 | if ssl_context is not None and keyfile is not None: |
| 1308 | raise ValueError("ssl_context and keyfile arguments are mutually " |
| 1309 | "exclusive") |
| 1310 | if ssl_context is not None and certfile is not None: |
| 1311 | raise ValueError("ssl_context and certfile arguments are mutually " |
| 1312 | "exclusive") |
| 1313 | if keyfile is not None or certfile is not None: |
| 1314 | import warnings |
| 1315 | warnings.warn("keyfile and certfile are deprecated, use a " |
| 1316 | "custom ssl_context instead", DeprecationWarning, 2) |
| 1317 | self.keyfile = keyfile |
| 1318 | self.certfile = certfile |
| 1319 | if ssl_context is None: |
| 1320 | ssl_context = ssl._create_stdlib_context(certfile=certfile, |
| 1321 | keyfile=keyfile) |
| 1322 | self.ssl_context = ssl_context |
| 1323 | IMAP4.__init__(self, host, port, timeout) |
| 1324 | |
| 1325 | def _create_socket(self, timeout): |
| 1326 | sock = IMAP4._create_socket(self, timeout) |