Skip to content
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

Native library (darwin-x86-64/libbitwarden_c.dylib) not found in resource path #1088

Open
1 task done
purejava opened this issue Sep 27, 2024 · 1 comment
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@purejava
Copy link

purejava commented Sep 27, 2024

Steps To Reproduce

Use Java bindings for a real world project and deploy it to different host architectures

Expected Result

Java bindings allow to use the Bitwarden Secrets Manager SDK on all host architectures the bitwarden_c library was compiled for

Actual Result

Native library (darwin-x86-64/libbitwarden_c.dylib) not found in resource path.

The same happens for Linux.

Screenshots or Videos

Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'bitwarden_c':
dlopen(libbitwarden_c.dylib, 0x0009): tried: 'libbitwarden_c.dylib' (relative path not allowed in hardened program), '/System/Volumes/Preboot/Cryptexes/OSlibbitwarden_c.dylib' (no such file), '/Applications/Cryptomator.app/Contents/Frameworks/libbitwarden_c.dylib' (no such file), '/Applications/Cryptomator.app/Contents/PlugIns/libbitwarden_c.dylib' (no such file), '/usr/lib/libbitwarden_c.dylib' (no such file, not in dyld cache), 'libbitwarden_c.dylib' (relative path not allowed in hardened program), '/usr/lib/libbitwarden_c.dylib' (no such file, not in dyld cache)
dlopen(libbitwarden_c.dylib, 0x0009): tried: 'libbitwarden_c.dylib' (relative path not allowed in hardened program), '/System/Volumes/Preboot/Cryptexes/OSlibbitwarden_c.dylib' (no such file), '/Applications/Cryptomator.app/Contents/Frameworks/libbitwarden_c.dylib' (no such file), '/Applications/Cryptomator.app/Contents/PlugIns/libbitwarden_c.dylib' (no such file), '/usr/lib/libbitwarden_c.dylib' (no such file, not in dyld cache), 'libbitwarden_c.dylib' (relative path not allowed in hardened program), '/usr/lib/libbitwarden_c.dylib' (no such file, not in dyld cache)
dlopen(/Users/ralph/Library/Frameworks/bitwarden_c.framework/bitwarden_c, 0x0009): tried: '/Users/ralph/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/ralph/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/Users/ralph/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file, not in dyld cache)
dlopen(/Library/Frameworks/bitwarden_c.framework/bitwarden_c, 0x0009): tried: '/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file, not in dyld cache)
dlopen(/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c, 0x0009): tried: '/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file), '/System/Library/Frameworks/bitwarden_c.framework/bitwarden_c' (no such file, not in dyld cache)
Native library (darwin-x86-64/libbitwarden_c.dylib) not found in resource path ([file:/Users/ralph/Library/Application%20Support/Cryptomator/Plugins/cryptomator-bitwarden-1.0.0.jar])
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:307)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:467)
	at com.sun.jna.Library$Handler.<init>(Library.java:192)
	at com.sun.jna.Native.load(Native.java:622)
	at com.sun.jna.Native.load(Native.java:596)
	at com.bitwarden.sdk.BitwardenClient.<init>(BitwardenClient.java:33)
	at org.purejava.integrations.keychain.BitwardenAccess.<init>(BitwardenAccess.java:41)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	... 58 common frames omitted

Additional Context

I used the Secrets Manager SDK Java bindings to build a Java application, that is a plug-in for Cryptomator, to store vault passwords in Bitwarden Secrets Manager.

Cryptomator is available for Windows, Linux and Mac, both Apple Intel and Apple Silicon. So the plug-in, using the SDK, should work on these host architectures .

The latest Maven artifact you released does not work an any architecture. The reason is a wong layout in the generated resource jar file. It contains a release path, so that the contained libbitwarden_c.dylib is stored under darwin-x86-64/release/libbitwarden_c.dylib, where the class loader can't find it.
Bildschirmfoto vom 2024-09-27 09-06-28

Removing the release part of the path solves the issue for all architectiues.

Operating System

macOS

Operating System Version

No response

Build Version

1.0.0

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@purejava purejava added the bug Something isn't working label Sep 27, 2024
@coltonhurst coltonhurst self-assigned this Oct 11, 2024
@coltonhurst
Copy link
Member

@purejava thanks for the report. This PR fixed this: #1107

Please look out for a new release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants