MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / starttls

Method starttls

tools/python-3.11.9-amd64/Lib/imaplib.py:809–829  ·  view source on GitHub ↗
(self, ssl_context=None)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 7

_simple_commandMethod · 0.95
_get_capabilitiesMethod · 0.95
_untagged_responseMethod · 0.95
errorMethod · 0.45
abortMethod · 0.45
wrap_socketMethod · 0.45
makefileMethod · 0.45

Tested by

no test coverage detected