Upgrade transport to TLS. Return a new transport that *protocol* should start using immediately.
(self, transport, protocol, sslcontext, *,
server_side=False,
server_hostname=None,
ssl_handshake_timeout=None,
ssl_shutdown_timeout=None)
| 1312 | await proto.restore() |
| 1313 | |
| 1314 | async def start_tls(self, transport, protocol, sslcontext, *, |
| 1315 | server_side=False, |
| 1316 | server_hostname=None, |
| 1317 | ssl_handshake_timeout=None, |
| 1318 | ssl_shutdown_timeout=None): |
| 1319 | """Upgrade transport to TLS. |
| 1320 | |
| 1321 | Return a new transport that *protocol* should start using |
| 1322 | immediately. |
| 1323 | """ |
| 1324 | if ssl is None: |
| 1325 | raise RuntimeError('Python ssl module is not available') |
| 1326 | |
| 1327 | if not isinstance(sslcontext, ssl.SSLContext): |
| 1328 | raise TypeError( |
| 1329 | f'sslcontext is expected to be an instance of ssl.SSLContext, ' |
| 1330 | f'got {sslcontext!r}') |
| 1331 | |
| 1332 | if not getattr(transport, '_start_tls_compatible', False): |
| 1333 | raise TypeError( |
| 1334 | f'transport {transport!r} is not supported by start_tls()') |
| 1335 | |
| 1336 | waiter = self.create_future() |
| 1337 | ssl_protocol = sslproto.SSLProtocol( |
| 1338 | self, protocol, sslcontext, waiter, |
| 1339 | server_side, server_hostname, |
| 1340 | ssl_handshake_timeout=ssl_handshake_timeout, |
| 1341 | ssl_shutdown_timeout=ssl_shutdown_timeout, |
| 1342 | call_connection_made=False) |
| 1343 | |
| 1344 | # Pause early so that "ssl_protocol.data_received()" doesn't |
| 1345 | # have a chance to get called before "ssl_protocol.connection_made()". |
| 1346 | transport.pause_reading() |
| 1347 | |
| 1348 | transport.set_protocol(ssl_protocol) |
| 1349 | conmade_cb = self.call_soon(ssl_protocol.connection_made, transport) |
| 1350 | resume_cb = self.call_soon(transport.resume_reading) |
| 1351 | |
| 1352 | try: |
| 1353 | await waiter |
| 1354 | except BaseException: |
| 1355 | transport.close() |
| 1356 | conmade_cb.cancel() |
| 1357 | resume_cb.cancel() |
| 1358 | raise |
| 1359 | |
| 1360 | return ssl_protocol._app_transport |
| 1361 | |
| 1362 | async def create_datagram_endpoint(self, protocol_factory, |
| 1363 | local_addr=None, remote_addr=None, *, |
nothing calls this directly
no test coverage detected