-
-
Notifications
You must be signed in to change notification settings - Fork 576
Open
Labels
Description
When testing using the CLI tool, doing things quick'n'dirty for testing purpose is, imho, acceptable, as long as it's explicitly stated in the CLI args, for example something like this?
python -m websockets --insecure wss://localhost:8085Imagine the following auto certif:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost"for this server:
#!/usr/bin/env python
import asyncio
import ssl
from websockets.asyncio.server import serve
async def handler(websocket):
while True:
message = await websocket.recv()
print(message)
async def main():
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(certfile="cert.pem", keyfile="key.pem")
async with serve(handler, "localhost", 8085, ssl=ssl_context) as server:
await asyncio.Future() # run forever
if __name__ == "__main__":
asyncio.run(main())