(self, ssl_context=None)
| 807 | |
| 808 | |
| 809 | def starttls(self, ssl_context=None): |
| 810 | name = 'STARTTLS' |
| 811 | if not HAVE_SSL: |
| 812 | raise self.error('SSL support missing') |
| 813 | if self._tls_established: |
| 814 | raise self.abort('TLS session already established') |
| 815 | if name not in self.capabilities: |
| 816 | raise self.abort('TLS not supported by server') |
| 817 | # Generate a default SSL context if none was passed. |
| 818 | if ssl_context is None: |
| 819 | ssl_context = ssl._create_stdlib_context() |
| 820 | typ, dat = self._simple_command(name) |
| 821 | if typ == 'OK': |
| 822 | self.sock = ssl_context.wrap_socket(self.sock, |
| 823 | server_hostname=self.host) |
| 824 | self.file = self.sock.makefile('rb') |
| 825 | self._tls_established = True |
| 826 | self._get_capabilities() |
| 827 | else: |
| 828 | raise self.error("Couldn't establish TLS session") |
| 829 | return self._untagged_response(typ, dat, name) |
| 830 | |
| 831 | |
| 832 | def status(self, mailbox, names): |
nothing calls this directly
no test coverage detected