Skip to content

Allow CLI to connect to custom "insecure" wss endpoints #1675

@abex-py

Description

@abex-py

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:8085

Imagine 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())

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions