postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
865 stars 94 forks source link

Install Problem #2442

Open Jon-G-Max opened 1 month ago

Jon-G-Max commented 1 month ago

What do you need help with?

Im sure this is a rookie error but do you have any idea why these errors are occurring? see errors below...

atvremote wizard 
Looking for devices...
Found the following devices:
    Name                       Model                Address
--  -------------------------  -------------------  -------------
 1  Grovers M1Max (2021)       MacBookPro18,2       192.168.1.151
 2  Dining Room                HomePod              192.168.1.180
 3  Basement                   Apple TV 4K (gen 3)  192.168.1.172
 4  MRX 540-42B9FA             MRX 540              192.168.1.183
 5  SONY XR-55A95K             XR-55A95K            192.168.1.191
 6  Living Room -Old Apple TV  Apple TV 4           192.168.1.153
 7  Family Room                Apple TV 4K (gen 3)  192.168.1.170
 8  Server 2024                Mac14,14             192.168.1.250
 9  Norma's MacBook Air        MacBookAir10,1       192.168.1.77
10  Server 2024                Mac14,14             192.168.1.232
Enter index of device to set up (q to quit): 7
Starting to set up Family Room
Starting to pair Protocol.Companion
Enter PIN on screen: 7308
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/auth.py", line 99, in finish_pairing
    encrypted_data = self.srp.step3(name=display_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/auth/hap_srp.py", line 202, in step3
    chacha = chacha20.Chacha20Cipher(self._session_key, self._session_key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/chacha20.py", line 14, in __init__
    self._enc_out = ChaCha20Poly1305(out_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/chacha20poly1305_reuseable/__init__.py", line 82, in __init__
    if not AEAD_CIPHER_SUPPORTED(TEST_CIPHER):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 572, in aead_cipher_supported
    return aead._aead_cipher_supported(self, cipher)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 22, in _aead_cipher_supported
    cipher_name = _evp_cipher_cipher_name(cipher)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 978, in _run_application
    return await cli_handler(loop)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 717, in cli_handler
    return await _exec_command(glob_cmds, args.command[0], print_result=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 945, in _exec_command
    value = await tmp(*args)
            ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 283, in wizard
    await self._wizard_pair(conf, service)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/scripts/atvremote.py", line 355, in _wizard_pair
    await pairing.finish()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/protocols/companion/pairing.py", line 58, in finish
    await error_handler(
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError

>>> An error occurred, full stack trace above
2024-07-17 15:08:24 ERROR [asyncio]: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x104aa5f10>
postlund commented 1 month ago

Based on this:

^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

I assume OpenSSL is built without support AES GCM. This is the default installation of Python in macOS, right? Not installed via brew?

Jon-G-Max commented 1 month ago

This is macOS Sonoma 14.5. Not sure what comes preinstalled as default... Ran these commands.... Is there a URL you can suggest to install missing components?

MyHost ~ % openssl version
LibreSSL 3.3.6
MyHost ~ % openssl enc -help 2>&1 | grep gcm
 -aes-128-ecb              -aes-128-gcm              -aes-128-ofb             
 -aes-192-ctr              -aes-192-ecb              -aes-192-gcm             
 -aes-256-ctr              -aes-256-ecb              -aes-256-gcm             
postlund commented 1 month ago

How did you install pyatv? I would recommend installing in a virtual environment. Looks to me like the cryptography library is quite old.

postlund commented 1 month ago

Can you try to install from master and see if you notice any difference?

Jon-G-Max commented 1 month ago

I apologize but I'm really a newbie to open source, command line development. I have a stock MacBook Pro running Sonoma 14.5. Is there a step by step instruction on how to install from master ? My install used pip. I would really love to get this running but I don't want to waste anyone's time.

postlund commented 1 month ago

I'm planning on making a new release quite soon, just waiting for some things to land. I'll let you know when it's ready, then you can just upgrade with pip.