diff options
Diffstat (limited to 'kvmd/apps/vnc/rfb/stream.py')
-rw-r--r-- | kvmd/apps/vnc/rfb/stream.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/kvmd/apps/vnc/rfb/stream.py b/kvmd/apps/vnc/rfb/stream.py index 843cfe54..49d86931 100644 --- a/kvmd/apps/vnc/rfb/stream.py +++ b/kvmd/apps/vnc/rfb/stream.py @@ -21,6 +21,7 @@ import asyncio +import ssl import struct from typing import Tuple @@ -102,6 +103,31 @@ class RfbClientStream: # ===== + async def _start_tls(self, ssl_context: ssl.SSLContext, ssl_timeout: float) -> None: + loop = asyncio.get_event_loop() + + ssl_reader = asyncio.StreamReader() + protocol = asyncio.StreamReaderProtocol(ssl_reader) + + transport = await loop.start_tls( + self.__writer.transport, + protocol, + ssl_context, + server_side=True, + ssl_handshake_timeout=ssl_timeout, + ) + + ssl_reader.set_transport(transport) + ssl_writer = asyncio.StreamWriter( + transport=transport, + protocol=protocol, + reader=ssl_reader, + loop=loop, + ) + + self.__reader = ssl_reader + self.__writer = ssl_writer + def _close(self) -> None: try: self.__writer.close() |