Skip to content

SSL by default, failover to plain #140

Open

Description

@klattimer

Some devices will support SSL, some will not, of those which do, some may support plaintext. It makes most sense for us to take the most secure option and failover to the least secure option.

Activity

  1. Tenzer commented on Dec 9, 2023

    @Tenzer
    Collaborator

    One slight complication with this for now, is that ws4py is using ssl.wrap_socket when SSL is enabled, which was marked as deprecated in Python 3.7 and removed in Python 3.12, so it makes lgtv fail like this:

    ~ % lgtv --ssl swInfo
    Traceback (most recent call last):
      File "/Users/jeppe/.local/bin/lgtv", line 33, in <module>
        sys.exit(load_entry_point('LGTV', 'console_scripts', 'lgtv')())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/jeppe/my-git/LGWebOSRemote/LGTV/__init__.py", line 191, in main
        ws.connect()
      File "/Users/jeppe/.local/pipx/venvs/lgtv/lib/python3.12/site-packages/ws4py/client/__init__.py", line 214, in connect
        self.sock = ssl.wrap_socket(self.sock, **self.ssl_options)
                    ^^^^^^^^^^^^^^^
    AttributeError: module 'ssl' has no attribute 'wrap_socket'
    

    There's a fix for ws4py in Lawouach/WebSocket-for-Python#283, but I wonder if it might otherwise be worth looking at migrating to another websocket library that is kept more up to date, as ws4py hasn't had a release since 2018?

  2. klattimer commented on Dec 11, 2023

    @klattimer
    OwnerAuthor

    @Tenzer ws4py was the only one I found that I could make work - specifically, I had to exclude default headers in order to make it work back on webOS 2.x IIRC. You'll find this in the code where exclude_headers=['Origin'] IIRC, which was always being sent by ws4py (it IS part of the spec, so you can't blame them).

    This is in itself a bit of a hack, and was likely due to a bug in the webOS web socket server libraries and may now have been fixed.

  3. Aurshur commented on Dec 30, 2023

    @Aurshur

    Is there any workaround with this?

    I tried @cmer 's suggestion of rolling back to Python 3.6 but got the following error:

    % brew install python@3.6
    Warning: No available formula with the name "python@3.6". Did you mean python@3.9, python@3.8, python@3.7, python@3.10, python@3.12, python@3.11 or python-yq?
    ==> Searching for similarly named formulae and casks...
    ==> Formulae
    python@3.9 python@3.8 python@3.7 python@3.10 python@3.12 python@3.11 python-yq

  4. Tenzer commented on Dec 30, 2023

    @Tenzer
    Collaborator

    The problem only exists with Python 3.12, so try version 3.11 for now.

  5. Aurshur commented on Jan 6, 2024

    @Aurshur

    The problem only exists with Python 3.12, so try version 3.11 for now.

    That worked! Thank you!

  6. egnappahz commented on Apr 28, 2024

    @egnappahz

    I'm sorry, but the real fix is
    https://github.com/Lawouach/WebSocket-for-Python/pull/283/files/1d9ffff3beb71553c85e846a1b828ec7d890e751

    Not all of us can afford to use ancient versions of python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions