MCPcopy Index your code
hub / github.com/python/cpython / stls

Method stls

Lib/poplib.py:408–427  ·  view source on GitHub ↗

Start a TLS session on the active connection as specified in RFC 2595. context - a ssl.SSLContext

(self, context=None)

Source from the content-addressed store, hash-verified

406
407
408 def stls(self, context=None):
409 """Start a TLS session on the active connection as specified in RFC 2595.
410
411 context - a ssl.SSLContext
412 """
413 if not HAVE_SSL:
414 raise error_proto('-ERR TLS support missing')
415 if self._tls_established:
416 raise error_proto('-ERR TLS session already established')
417 caps = self.capa()
418 if not 'STLS' in caps:
419 raise error_proto('-ERR STLS not supported by server')
420 if context is None:
421 context = ssl._create_stdlib_context()
422 resp = self._shortcmd('STLS')
423 self.sock = context.wrap_socket(self.sock,
424 server_hostname=self.host)
425 self.file = self.sock.makefile('rb')
426 self._tls_established = True
427 return resp
428
429
430if HAVE_SSL:

Callers 3

test_stlsMethod · 0.45
test_stls_contextMethod · 0.45
setUpMethod · 0.45

Calls 5

capaMethod · 0.95
_shortcmdMethod · 0.95
wrap_socketMethod · 0.80
error_protoClass · 0.70
makefileMethod · 0.45

Tested by 3

test_stlsMethod · 0.36
test_stls_contextMethod · 0.36
setUpMethod · 0.36