(self, ssl_context=None)
| 912 | |
| 913 | |
| 914 | def starttls(self, ssl_context=None): |
| 915 | name = 'STARTTLS' |
| 916 | if not HAVE_SSL: |
| 917 | raise self.error('SSL support missing') |
| 918 | if self._tls_established: |
| 919 | raise self.abort('TLS session already established') |
| 920 | if name not in self.capabilities: |
| 921 | raise self.abort('TLS not supported by server') |
| 922 | # Generate a default SSL context if none was passed. |
| 923 | if ssl_context is None: |
| 924 | ssl_context = ssl._create_stdlib_context() |
| 925 | typ, dat = self._simple_command(name) |
| 926 | if typ == 'OK': |
| 927 | self.sock = ssl_context.wrap_socket(self.sock, |
| 928 | server_hostname=self.host) |
| 929 | self._file = self.sock.makefile('rb') |
| 930 | self._tls_established = True |
| 931 | self._get_capabilities() |
| 932 | else: |
| 933 | raise self.error("Couldn't establish TLS session") |
| 934 | return self._untagged_response(typ, dat, name) |
| 935 | |
| 936 | |
| 937 | def status(self, mailbox, names): |
nothing calls this directly
no test coverage detected