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

Current master pkcs11-tool fails to load default module #1443

Closed
mouse07410 opened this issue Aug 7, 2018 · 3 comments
Closed

Current master pkcs11-tool fails to load default module #1443

mouse07410 opened this issue Aug 7, 2018 · 3 comments

Comments

@mouse07410
Copy link
Contributor

Problem Description

$ pkcs11-tool --verbose -L
sc_dlopen failed: dlopen(, 1): no suitable image found.  Did find:
	/usr/local/lib/: not a file
	/usr/local/lib: not a file
	/usr/lib/: not a file
	/usr/lib: not a file
error: Failed to load pkcs11 module
Aborting.

$ pkcs11-tool --module /Library/OpenSC/lib/opensc-pkcs11.dylib --verbose -L
Available slots:
Slot 0 (0x0): Yubico Yubikey 4 OTP+U2F+CCID
  manufacturer:  
  hardware ver:  4.55
  firmware ver:  0.0
  flags:         token present, removable device, hardware slot
  token label        : . . . . .
  . . . . .
  pin min/max        : 4/8
$ 

Proposed Resolution

Set DEFAULT_PKCS11_PROVIDER in a config file other than win32/winconfig.h.

Apparently this:

MacOSX/Makefile:153:DEFAULT_PKCS11_PROVIDER = ${exec_prefix}/lib/opensc-pkcs11.so

is not enough.

Steps to reproduce

Run the above commands.

Logs

Nothing. :-(

mouse07410 added a commit to mouse07410/OpenSC that referenced this issue Aug 8, 2018
@Jakuje
Copy link
Member

Jakuje commented Aug 8, 2018

This looks like an issue also on Linux -- the config.h no longer lists DEFAULT_PKCS11_PROVIDER for me and while the path is correctly reported in the configure, the string is nowhere to be found in the pkcs11-tool binary nor the tool works without explicit specification of the module path.

@mouse07410
Copy link
Contributor Author

Which is why I've reverted that change in my fork:

diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index b35a6465..4782f7f8 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -39,7 +39,8 @@ endif
 
 # compile with $(PTHREAD_CFLAGS) to allow debugging with gdb
 AM_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) $(OPTIONAL_READLINE_CFLAGS) $(PTHREAD_CFLAGS)
-AM_CPPFLAGS = -I$(top_srcdir)/src -D'DEFAULT_PKCS11_PROVIDER="$(DDEFAULT_PKCS11_PROVIDER)"'
+#AM_CPPFLAGS = -I$(top_srcdir)/src -D'DEFAULT_PKCS11_PROVIDER="$(DDEFAULT_PKCS11_PROVIDER)"'
+AM_CPPFLAGS = -I$(top_srcdir)/src
 LIBS = \
        $(top_builddir)/src/libopensc/libopensc.la \
        $(top_builddir)/src/common/libscdl.la \
diff --git a/configure.ac b/configure.ac
index a0212891..d2cdf975 100644
--- a/configure.ac
+++ b/configure.ac
@@ -894,6 +894,7 @@ if test "${with_pkcs11_provider}" = "detect"; then
 else
        DEFAULT_PKCS11_PROVIDER="${with_pkcs11_provider}"
 fi
+AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_PROVIDER], ["${DEFAULT_PKCS11_PROVIDER}"], [Default PKCS11 provider])
 
 if test "${enable_man}" = "detect"; then
        if test "${WIN32}" = "yes"; then

And for MacOS:

diff --git a/MacOSX/build-package.in b/MacOSX/build-package.in
index 834e4a16..ac56194e 100755
--- a/MacOSX/build-package.in
+++ b/MacOSX/build-package.in
@@ -66,12 +92,14 @@ if ! test -e ${BUILDPATH}/target/$PREFIX/lib/pkgconfig; then
                --enable-static \
                --enable-strict \
                --disable-assert \
+               --disable-silent-rules \
+               --with-pkcs11-provider=$PREFIX/lib/opensc-pkcs11.so \
                --enable-sm # TODO: remove this (must be sensible default in master)
 
        # always make clean
        make clean
 
        # compile
-       make -j 2
+       make V=1 -j 4
 

It worked when DEFAULT_PKCS11_PROVIDER was passed via config.h. It should stay there.

@frankmorgner
Copy link
Member

It's complicated working around autoconf's magic that handles DESTDIR and PREFIX...

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

No branches or pull requests

3 participants