crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 768 forks source link

wss:// URIs are not recognized #1595

Closed francisATgwn closed 2 years ago

francisATgwn commented 2 years ago

Steps to Reproduce

  1. use twisted
  2. run the example from the docs

requirements.txt

autobahn[twisted]
cbor2
pyOpenSSL

main.py

from autobahn.twisted.component import Component
from autobahn.twisted.component import run

comp = Component(
    transports="wss://demo.crossbar.io/ws",
    realm="realm1",
)

@comp.on_join
def joined(session, details):
    print("session ready")

if __name__ == "__main__":
    run([comp])

Expected Result

"session ready" is logged

Actual Result

2022-08-23T13:41:32-0400 trying transport 0 ("wss://demo.crossbar.io/ws") using connect delay 0
2022-08-23T13:41:32-0400 connecting once using transport type "websocket" over endpoint "tcp"
2022-08-23T13:41:32-0400 SSL error: unregistered scheme (in )
2022-08-23T13:41:32-0400 TLS failure: unregistered scheme

Notes

This works as expected (or at least gets further, to a self-signed cert error) using asyncio.

requirements.txt:

autobahn[asyncio]
cbor2

main.py:

from autobahn.asyncio.component import Component
from autobahn.asyncio.component import run

comp = Component(
    transports="wss://demo.crossbar.io/ws",
    realm="realm1",
)

@comp.on_join
async def joined(session, details):
    print("session ready")

if __name__ == "__main__":
    run([comp])
francisATgwn commented 2 years ago

I dug around a little and found lib/python3.10/site-packages/autobahn/wamp/component.py which has handle_connect_error where the error message originates from. I couldn't make sense of the values from this bit

ssl_lib, ssl_func, ssl_reason = fail.value.args[0][0]

the tuple is ('STORE routines', '', 'unregistered scheme'). From there, I'm lost. I can't find where the twisted implementation is opening the TLS session and whatever it might be calling in openssl that results in the unregistered scheme.

oberstet commented 2 years ago

No idea, likely upstream? I think it's better to track this for now where a discussion already has started https://github.com/pyca/cryptography/issues/7488