Syndace / python-omemo

An open python implementation of the OMEMO Multi-End Message and Object Encryption protocol.
MIT License
41 stars 6 forks source link

encryption for outgoing messages failed #34

Closed fantomfp closed 3 years ago

fantomfp commented 3 years ago

Hi, I'm having an issue for outgoing messages I use these versions:

This stack can be found for Fedora at https://copr.fedorainfracloud.org/coprs/fantom/poezio-omemo/ When I use python-omemo 0.12.0, it doen't work, but when I used python-omemo 0.11.0, it worked.

I have a traceback in the debug.log file:

2021-04-04 16:09:19,257 ERROR:plugin_e2ee:Exception in encrypt:
Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/poezio/plugin_e2ee.py", line 329, in _encrypt_wrapper
    result = await self._encrypt(stanza, passthrough=True)
  File "/usr/lib64/python3.9/site-packages/poezio/plugin.py", line 96, in async_helper
    return await f(*args, **kwargs)
  File "/usr/lib64/python3.9/site-packages/poezio/plugin_e2ee.py", line 457, in _encrypt
    await func(message, jids, tab, passthrough=True)
  File "/usr/lib64/python3.9/site-packages/poezio/plugin.py", line 96, in async_helper
    return await f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/poezio_omemo/__init__.py", line 168, in encrypt
    encrypt = await self.core.xmpp['xep_0384'].encrypt_message(
  File "/usr/lib/python3.9/site-packages/slixmpp_omemo/__init__.py", line 586, in encrypt_message
    encrypted = self._omemo.encryptMessage(
  File "/usr/lib/python3.9/site-packages/omemo/sessionmanager.py", line 127, in encryptMessage
    return self.__encryptKeyTransportMessage(
  File "/usr/lib/python3.9/site-packages/omemo/promise.py", line 319, in __maybe_coroutine
    return no_coroutine(f)(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/omemo/promise.py", line 267, in _no_coroutine
    element = generator.send(previous)
  File "/usr/lib/python3.9/site-packages/omemo/sessionmanager.py", line 232, in __encryptKeyTransportMessage
    encrypt_for[self.__my_bare_jid].remove(self.__my_device_id)
KeyError: 'jid@jid.jid'

In my config file, I have set a long time ago the device_id

device_id = <random_string_here>

I think the issue is located on the ressource parsing, because the ressource is "jid@jid.com/poezio-[device_id]". Let me know if the problem come from the plugin itself...

fantomfp commented 3 years ago

Found the solution. When upgrading from python-omemo 0.11.0 to 0.12.0, you need to clear the user data: $ mv .local/share/poezio/omemo ~/ Then it works.