Siyuanw/kinesis

AttributeError: '_RSAPrivateKey' object has no attribute 'write'

hunchu opened this issue ยท 9 comments

hunchu commented

Hi

I typed sudo python3 main.py at the very end of process.
and poped up

AttributeError: '_RSAPrivateKey' object has no attribute 'write'

How can I fix it?

thank you for your help.

hunchu commented

Os 17 m2 macbook air

I have the same error, here is the error traceback:

Exception in callback _SelectorDatagramTransport._read_ready()
handle: <Handle _SelectorDatagramTransport._read_ready()>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 1169, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/asyncio/protocol.py", line 135, in datagram_received
    self._quic.receive_datagram(cast(bytes, data), addr, now=self._loop.time())
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 1026, in receive_datagram
    is_ack_eliciting, is_probing = self._payload_received(
                                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 2334, in _payload_received
    frame_handler(context, frame_type, buf)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 1554, in _handle_crypto_frame
    self.tls.handle_message(event.data, self._crypto_buffers)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/tls.py", line 1494, in handle_message
    self._client_handle_hello(input_buf, output_buf[Epoch.INITIAL])
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/tls.py", line 1716, in _client_handle_hello
    self._setup_traffic_protection(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/tls.py", line 2196, in _setup_traffic_protection
    self.update_traffic_key_cb(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 2637, in _update_traffic_key
    secrets_log_file.write(
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_RSAPrivateKey' object has no attribute 'write'
Traceback (most recent call last):
  File "/Users/user/kinesis/kinesis-main/main.py", line 84, in <module>
    create_tunnel()
  File "/Users/user/kinesis/kinesis-main/main.py", line 79, in create_tunnel
    asyncio.run(start_quic_tunnel(rsd))
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/user/kinesis/kinesis-main/main.py", line 53, in start_quic_tunnel
    async with service.start_quic_tunnel(private_key) as tunnel_result:
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pymobiledevice3/remote/core_device_tunnel_service.py", line 349, in start_quic_tunnel
    async with aioquic_connect(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/asyncio/client.py", line 97, in connect
    await protocol.wait_connected()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/asyncio/protocol.py", line 127, in wait_connected
    await asyncio.shield(self._connected_waiter)
ConnectionError

python version: Python 3.11.7

Hiding the code can fix the problem, but it is not the exact solution.

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 2637:

secrets_log_file.write( "%s %s %s\n" % (label, self.tls.client_random.hex(), secret.hex()) ) secrets_log_file.flush()

same issue, can anyone share your pip freeze > requirements.txt ?

Hiding the code can fix the problem, but it is not the exact solution.

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/qh3/quic/connection.py", line 2637:

secrets_log_file.write( "%s %s %s\n" % (label, self.tls.client_random.hex(), secret.hex()) ) secrets_log_file.flush()

still doesn't work

Problem solved. I reinstalled pymobiledevice3 in previous version (2.30.1) and it worked without error.

Hello there,

I've addressed the connection issue in this PR #32 based on the latest version of pymobiledevice3. The modifications seem to resolve the problem, but I'd appreciate it if you could review and test the changes to ensure everything is working perfectly.

Thank you for your time and consideration.

@kkpan11 I checked out to PR #32 and it fixed the issue fore me, app is working fine on my device.
Thank you!

kudos @kkpan11, this works excellently!