def __init__(self, context=None): if context is None: self.context = utils.create_context() else: self.context = context self.logger = SSLLogger(type(self).__name__)
def run_case(protocol, cipher_suite): _context = utils.create_context(min_protocol=protocol, max_protocol=protocol, cipher_suites=(cipher_suite, )) _c_thread = ClientThread(Client(context=_context), _port) _c_thread.start() return _c_thread
def run_case(protocol, cipher_suite): print(f'Protocol: {protocol}\nCipher suite: {cipher_suite}') with ServerThread(Server()) as _s_thread: _s_thread.start() _port = _s_thread.server.get_port() _context = utils.create_context(min_protocol=protocol, max_protocol=protocol, cipher_suites=(cipher_suite, )) with Client(context=_context) as _client: _client.connect(port=_port)
from pyssldemo.server import Server, ServerThread @utils.func_separator() def run_case(context, port): print(f'Protocol: {utils.tls_protocol(context.minimum_version).value.name}') with Client(context) as _client1: _client1.connect(port=port) _session = _client1.get_session() with Client(context=_client1.context, session=_session) as _client2: _client2.connect(port=port) if not _client2.is_session_resumed(): raise RuntimeWarning('Session is not resumed') else: print('Session was resumed') if __name__ == '__main__': print(ssl.OPENSSL_VERSION) with ServerThread(Server()) as _s_thread: _s_thread.start() _port = _s_thread.server.get_port() for _protocol in (Protocols.TLSV1_2, Protocols.TLSV1_3): _context = utils.create_context(min_protocol=_protocol, max_protocol=_protocol) run_case(_context, _port)