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

Method starttls

tools/python-3.11.9-amd64/Lib/nntplib.py:993–1014  ·  view source on GitHub ↗

Process a STARTTLS command. Arguments: - context: SSL context to use for the encrypted connection

(self, context=None)

Source from the content-addressed store, hash-verified

991
992 if _have_ssl:
993 def starttls(self, context=None):
994 """Process a STARTTLS command. Arguments:
995 - context: SSL context to use for the encrypted connection
996 """
997 # Per RFC 4642, STARTTLS MUST NOT be sent after authentication or if
998 # a TLS session already exists.
999 if self.tls_on:
1000 raise ValueError("TLS is already enabled.")
1001 if self.authenticated:
1002 raise ValueError("TLS cannot be started after authentication.")
1003 resp = self._shortcmd('STARTTLS')
1004 if resp.startswith('382'):
1005 self.file.close()
1006 self.sock = _encrypt_on(self.sock, context, self.host)
1007 self.file = self.sock.makefile("rwb")
1008 self.tls_on = True
1009 # Capabilities may change after TLS starts up, so ask for them
1010 # again.
1011 self._caps = None
1012 self.getcapabilities()
1013 else:
1014 raise NNTPError("TLS failed to start.")
1015
1016
1017if _have_ssl:

Callers 1

nntplib.pyFile · 0.45

Calls 7

_shortcmdMethod · 0.95
getcapabilitiesMethod · 0.95
_encrypt_onFunction · 0.85
NNTPErrorClass · 0.85
startswithMethod · 0.80
closeMethod · 0.45
makefileMethod · 0.45

Tested by

no test coverage detected