Skip to content

use MacOS builtin security framework instead of homebrew #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rob-miller
Copy link

Admittedly with help from Claude and many hours trying different things, this works on my MacOS system to install and use the acsm calibre plugin with homebrew installed openssl@3 without 'brew un/link openssl@3'. Basically this just uses the system crypto libraries if they are available.

With this change to init.py, I can successfully load the plugin on MacOS Sequoia 15.4 with homebrew installed (and linked) openssl@3 and then drag in .acsm files and get the epub loaded.

Closes #106 and better addresses #109, #65 and #63.

@Leseratte10
Copy link
Owner

Thanks for the MR. I do not have a Mac to test this, though, so I'd prefer to get some feedback from other MacOS users if this fixes some of the outstanding issues on MacOS.

Also, I noticed that you hard-coded "libcrypto.46.dylib" and "libssl.46.dylib" - is this a good idea / is this always the file name on all versions of MacOS and unlikely to change in the future? Or can this be made to dynamically find the proper file name?

@rob-miller rob-miller force-pushed the macos-homebrew-openssl-fix branch from 0190906 to ce0ef87 Compare May 10, 2025 20:38
re-write with better understanding of Mac security framework and dyld shared cache
@rob-miller rob-miller force-pushed the macos-homebrew-openssl-fix branch from 6a85ac4 to d145292 Compare May 10, 2025 21:04
@rob-miller
Copy link
Author

I thought the 'lib*.46.dylib' was just a last resort as a default to return, but it turns out that is what is needed for loading libadobe on MacOS with Homebrew openssl libs.

MacOS doesn't actually have the files in its directory, but they are in its 'dyld shared cache' to be loaded. If you try to load something more generic like /usr/lib/libcrypto.dylib the OS will crash your entire program with an error saying "don't do that, the API is not stable". Explicitly using the Apple Security Framework as I had before does not work because libadobe looks for 'OpenSSL version' which is not available.

So this code tries the .46 version (available since 2020) and then the .35 version (available since 2015) and tests loading libadobe for each; if neither works it gives up with a message seen if running in the terminal.

There's also:

  • code to get the environment variables on a Mac if running from a terminal instead of the GUI
  • avoids checking if the path exists when loading libraries specified in env variables on Mac, as the files are probably not there

How do we find someone else with a Mac to review this? Add to the Mobilread thread?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to install Plugin on Mac
2 participants