File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -455,3 +455,32 @@ given amount of time.
455455
456456 There's one drawback though: the test takes 2 seconds to run as it waits the
457457handler thread to be completed.
458+
459+
460+ Running and HTTPS server
461+ ------------------------
462+
463+ To run an https server, `trustme ` can be used to do the heavy lifting:
464+
465+ .. code-block :: python
466+
467+ @pytest.fixture (scope = " session" )
468+ def ca ():
469+ return trustme.CA()
470+
471+
472+ @pytest.fixture (scope = " session" )
473+ def localhost_cert (ca ):
474+ return ca.issue_cert(" localhost" )
475+
476+
477+ @pytest.fixture (scope = " session" )
478+ def httpserver_ssl_context (localhost_cert ):
479+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER )
480+
481+ crt = localhost_cert.cert_chain_pems[0 ]
482+ key = localhost_cert.private_key_pem
483+ with crt.tempfile() as crt_file, key.tempfile() as key_file:
484+ context.load_cert_chain(crt_file, key_file)
485+
486+ return context
You can’t perform that action at this time.
0 commit comments