Skip to content

Conversation

@ye4241
Copy link

@ye4241 ye4241 commented Dec 6, 2025

This pull request enhances the way the getYkcs11Library() method in YubiKey.java locates the YubiKey PKCS#11 library, making it more flexible and robust, especially for custom and MacOS environments.

Improvements to library discovery:

  • Added support for specifying a custom PKCS#11 library path via the PKCS11_MODULE environment variable, allowing users to override the default search logic.
  • Improved MacOS support by searching multiple common locations for libykcs11.dylib, including paths from the DYLD_LIBRARY_PATH environment variable, increasing compatibility with different installation methods.

@ye4241 ye4241 changed the title Add support for locating ykcs11 library on macOS with homebrew Add support for locating ykcs11 library on macOS Dec 6, 2025
@ebourg
Copy link
Owner

ebourg commented Dec 7, 2025

Thank you for the suggestion. Do you know which Homebrew package provides libykcs11.dylib? I couldn't find it.

I'm not familiar with macOS, in which case is DYLD_LIBRARY_PATH used?

I'm not convinced by the PKCS11_MODULE environment variable, I tend to think that for a custom path to libykcs11 the best is to use the PKCS11 storetype with a standard SunPKCS configuration file specifying the path to the library.

Also keep in mind that you can replace the YUBIKEY storetype with PIV and simply ditch the ykcs11 library (in this mode Jsign bypasses the PKCS#11 library and talks to the Yubikey directly).

@ebourg
Copy link
Owner

ebourg commented Dec 7, 2025

Do you know which Homebrew package provides libykcs11.dylib? I couldn't find it.

Ok got it, it comes from the yubico-piv-tool formulae.

We could also add the Linux path: /home/linuxbrew/.linuxbrew/lib/libykcs11.so

@ye4241
Copy link
Author

ye4241 commented Dec 8, 2025

I'm not familiar with macOS, in which case is DYLD_LIBRARY_PATH used?

DYLD_LIBRARY_PATH is an environment variable in macOS, used to specify directories where the system should search for dynamic library (.dylib) files. It helps the operating system locate the necessary libraries during the execution of programs.

I'm not convinced by the PKCS11_MODULE environment variable, I tend to think that for a custom path to libykcs11 the best is to use the PKCS11 storetype with a standard SunPKCS configuration file specifying the path to the library.

Let me remove this logic first.

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.

2 participants