Leseratte10 / acsm-calibre-plugin

Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=341975
GNU General Public License v3.0
600 stars 23 forks source link

"No module named libadobe" when attempting to import plugin #20

Closed rossohill closed 2 years ago

rossohill commented 2 years ago

Bug description

"Invalid Plugin" error when attempting to import plugin, first time installing. Looks like there are two modules it can't find, libadobe and oscrypto. Error message:

calibre, version 5.41.0
ERROR: Unhandled exception: <b>InvalidPlugin</b>:Initialization of plugin Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 184, in initialize
  File "calibre\customize\zipplugin.py", line 191, in exec_module
  File "calibre_plugins.deacsm.libadobe", line 29, in &lt;module&gt;
ModuleNotFoundError: No module named 'oscrypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 673, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 187, in initialize
ModuleNotFoundError: No module named 'libadobe'
 failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 184, in initialize
  File "calibre\customize\zipplugin.py", line 191, in exec_module
  File "calibre_plugins.deacsm.libadobe", line 29, in &lt;module&gt;
ModuleNotFoundError: No module named 'oscrypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 673, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 187, in initialize
ModuleNotFoundError: No module named 'libadobe'

calibre 5.41  embedded-python: True is64bit: False
Windows-10-10.0.19041 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', '', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (7, 2, 1)
Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 184, in initialize
  File "calibre\customize\zipplugin.py", line 191, in exec_module
  File "calibre_plugins.deacsm.libadobe", line 29, in <module>
ModuleNotFoundError: No module named 'oscrypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 673, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 187, in initialize
ModuleNotFoundError: No module named 'libadobe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\gui2\preferences\plugins.py", line 326, in add_plugin
  File "calibre\customize\ui.py", line 483, in add_plugin
  File "calibre\customize\ui.py", line 678, in initialize_plugin
calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 184, in initialize
  File "calibre\customize\zipplugin.py", line 191, in exec_module
  File "calibre_plugins.deacsm.libadobe", line 29, in <module>
ModuleNotFoundError: No module named 'oscrypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 673, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 187, in initialize
ModuleNotFoundError: No module named 'libadobe'
 failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 184, in initialize
  File "calibre\customize\zipplugin.py", line 191, in exec_module
  File "calibre_plugins.deacsm.libadobe", line 29, in <module>
ModuleNotFoundError: No module named 'oscrypto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre\customize\ui.py", line 673, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 187, in initialize
ModuleNotFoundError: No module named 'libadobe'

Thanks for your time.

Operating system

Windows

Which version of Calibre are you running?

v5.41.0

Which version of the DeACSM plugin are you running?

v0.0.15

Further information

No response

zoof commented 2 years ago

I can confirm this on a Pop!_OS 22.04 system with Calibre 5.37. System Python is 3.10.

Leseratte10 commented 2 years ago

Both libadobe and oscrypto come with the plugin, so I'm confused as to why it wouldn't be able to find them ... You did download the "DeACSM_0.0.15.zip" file from the release page, not the source code bundle?

The issue on PopOS 22.04 or any system based on Ubuntu 22.04 is a known issue with OpenSSL 3.0 which will be fixed with the next release of this plugin.

Leseratte10 commented 2 years ago

Can you test the latest change in commit b9f6672a4c0a55f6da17031f4b3492d835ed8a99 (download link https://github.com/Leseratte10/acsm-calibre-plugin/suites/6333118833/artifacts/227911219 )?

That should fix the issue on Ubuntu 22.04, maybe it also fixes the issue on Windows. I don't yet have a machine with Ubuntu 22.04 so I can't easily test this myself.

zoof commented 2 years ago

It installed but I was unable to add an acsm book. Do I need to completely reinitialize DeACSM?

zoof commented 2 years ago

I completedly deleted DeACSM and reinstalled it and when I tried to create an anonymous authorization, I got the following error:

calibre 5.37  embedded-python: False is64bit: True
Linux-5.16.19-76051619-generic-x86_64-with-glibc2.35 Linux ('64bit', 'ELF')
('Linux', '5.16.19-76051619-generic', '#202204081339~1649696161~22.04~091f44b SMP PREEMPT Mon Apr 11 17')
Python 3.10.4
Interface language: None
Successfully initialized third party plugins: DeACSM (0, 0, 15) && DeDRM (10, 0, 2)
Traceback (most recent call last):
  File "calibre_plugins.deacsm.config", line 1032, in create_anon_auth
    success, resp = activateDevice(idx, None)
  File "/home/user/.config/calibre/plugins/DeACSM.zip/libadobeAccount.py", line 828, in activateDevice
    signature = sign_node(req_xml)
  File "/home/user/.config/calibre/plugins/DeACSM.zip/libadobe.py", line 518, in sign_node
    my_priv_key, _, _ = keys.parse_pkcs12(my_pkcs12, base64.b64encode(devkey_bytes))
  File "/home/user/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/asymmetric.py", line 800, in parse_pkcs12
    return _parse_pkcs12(data, password, load_private_key)
  File "/home/user/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 868, in _parse_pkcs12
    decrypted_content = _decrypt_encrypted_data(encryption_algorithm_info, encrypted_content, password)
  File "/home/user/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 1038, in _decrypt_encrypted_data
    plaintext = decrypt_func(enc_key, encrypted_content, enc_iv)
  File "/home/user/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/symmetric.py", line 358, in rc2_cbc_pkcs5_decrypt
    raise EnvironmentError('OpenSSL has been compiled without RC2 support')
OSError: OpenSSL has been compiled without RC2 support
Leseratte10 commented 2 years ago

Damnit. Looks like Ubuntu 22.04 completely dropped support for that ancient encryption Adobe uses. I've opened a bug report in the oscrypto repo asking its developer for clarification ( https://github.com/wbond/oscrypto/issues/60 ), but if I'm reading the code correctly, I'll have to find a different solution for that pkcs12 parsing ...

Leseratte10 commented 2 years ago

Okay, I've set up a workaround that seems to work for me, now I just need to make sure it doesn't break older Linuxes and then I can add that until oscrypto is fixed.

zoof commented 2 years ago

Let me know if there is anything I can do to help. Thank you for your work on this awesome plugin!

Leseratte10 commented 2 years ago

Managed to fix the root cause of the issue in the oscrypto library: https://github.com/wbond/oscrypto/pull/61 I'm going to wait a couple days and see if that gets merged / fixed in oscrypto (then I can just use the new release), otherwise I'm going to include a patched version of oscrypto in my plugin as a temporary fix until this PR gets merged. Thanks for the reports and logs.

erdoukki commented 2 years ago

Can you test the latest change in commit b9f6672 (download link https://github.com/Leseratte10/acsm-calibre-plugin/suites/6333118833/artifacts/227911219 )?

That should fix the issue on Ubuntu 22.04, maybe it also fixes the issue on Windows. I don't yet have a machine with Ubuntu 22.04 so I can't easily test this myself.

Tested yesterday : OK I have an error message in the plugin GUI while trying to access to the Options. I just read and removed some (2 or 3) bad characters from the end of an options XML Then all works fine again with the artficats proposed for testing purpose !

calibre (calibre 5.42)

Thanks

Leseratte10 commented 2 years ago

@zoof As my change to the oscrypto library still hasn't been merged, I modded the plugin so that it patches the library itself. As of d66913c1aed97148fa9d617a9e15ca83ad120ab6 the plugin should now work with Ubuntu 22.04.

If you had previously installed an older version of the plugin on Ubuntu 22.04, it might take two restarts of Calibre after the update until the plugin works properly. If it's a fresh install of the plugin, one restart should be enough.

zoof commented 2 years ago

Thank you! It works for me now.

Leseratte10 commented 2 years ago

Thanks for the response. The fix will be included in the next release then (either with the current workaround or with the updated library), so I'm going to close this issue.