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