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
593 stars 23 forks source link

Plugin cannot install/initialize due to `OSError: dlopen(libcrypto.dylib)` #63

Closed notEthan closed 10 months ago

notEthan commented 10 months ago

Bug description

DeACSM is failing to install due to failing to dlopen libcrypto. The relevant error appears to be: OSError: dlopen(/usr/local/lib/libcrypto.dylib, 0x0006): tried: '/usr/local/lib/libcrypto.dylib' (code signature in <1FCD44A2-E972-3D3D-95D1-4B7BF8459E95> '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.) Full trace is below.

I had Calibre successfully importing acsm previously, though I had both this and DeDRM installed and I don't recall which I actually had doing the import decryption. Something changed since my last successful import a couple months ago - possibly because I upgraded from macOS 12 (Monterey) to 13 (Ventura), not sure.

/usr/local/lib/libcrypto.dylib is a symlink to /usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib, installed by Homebrew (and freshly upgraded from 3.1.1 to see if that would fix this problem). Homebrew seems to not sign this; I tried signing it ad-hoc with codesign --sign - /usr/local/lib/libcrypto.dylib but it just changed the error message to not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

I'm not sure if the right place for this issue is here, or with the Python oscrypto lib, or with Homebrew. I also see somebody on MobileRead encountering the same issue: https://www.mobileread.com/forums/showthread.php?p=4341213

Full trace: ``` calibre 6.22 embedded-python: True macOS-13.5.1-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '22.6.0', 'Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64') Python 3.10.1 OSX: ('13.5.1', ('', '', ''), 'x86_64') Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) QPA platform: cocoa Starting QuickView 2023-08-21 13:44:58.206 calibre-debug[26453:2678849] +[CATransaction synchronize] called within transaction 2023-08-21 13:44:58.395 calibre-debug[26453:2678849] +[CATransaction synchronize] called within transaction Traceback (most recent call last): File "calibre_plugins.deacsm.__init__", line 226, in initialize from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest File "/Users/ethan/in/firefox/DeACSM_0.0.16.zip/libadobe.py", line 59, in from oscrypto import keys File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in from ._asymmetric import parse_certificate, parse_private, parse_public File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in from .kdf import pbkdf1, pbkdf2, pkcs12_kdf File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in from .util import rand_bytes File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 10, in from ._mac.util import rand_bytes File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_mac/util.py", line 208, in from .._openssl._libcrypto import libcrypto File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in from ._libcrypto_ctypes import ( File "/Users/ethan/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 30, in libcrypto = CDLL(libcrypto_path, use_errno=True) File "ctypes/__init__.py", line 374, in __init__ OSError: dlopen(/usr/local/lib/libcrypto.dylib, 0x0006): tried: '/usr/local/lib/libcrypto.dylib' (code signature in <1FCD44A2-E972-3D3D-95D1-4B7BF8459E95> '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libcrypto.dylib' (no such file), '/usr/local/lib/libcrypto.dylib' (code signature in <1FCD44A2-E972-3D3D-95D1-4B7BF8459E95> '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' (code signature in <1FCD44A2-E972-3D3D-95D1-4B7BF8459E95> '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' (no such file), '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' (code signature in <1FCD44A2-E972-3D3D-95D1-4B7BF8459E95> '/usr/local/Cellar/openssl@3/3.1.2/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.) ```

Operating system

MacOS

Which version of Calibre are you running?

6.22.0

Which version of the ACSM Input plugin are you running?

v0.0.16

Import type

No response

Further information

No response

ZolaLa9 commented 10 months ago

FWIW, I have been running v0.0.16 with macOS Ventura, so the problem does not appear to be an incompatibility with Ventura.

Leseratte10 commented 10 months ago

I've never used a Mac so I can't really debug these issues. On Mobileread the same user reported that unlinking openssl helped - brew unlink openssl@3. Or try to remove openssl and reinstall it to see if that fixes stuff, maybe there's some remains from the MacOS 12 version.

notEthan commented 10 months ago

Thank you, brew unlink openssl@3 was all I needed. I somehow missed the posts following up on the one I linked on MobileRead that suggested this solution. ACSMs are importing again, thank you for your response and for this excellent plugin.