CardContact / sc-hsm-embedded

PKCS#11 and CSP-Minidriver library for the SmartCard-HSM and STARCOS based signature cards
BSD 3-Clause "New" or "Revised" License
98 stars 31 forks source link

Path issue with sc-hsm-pkcs11-test in mac package #34

Closed mistial-dev closed 2 years ago

mistial-dev commented 2 years ago

Using the TLS 1.3 release, installed using the standard package. The PKCS11 unit test appears to expect to use the linux .so file, rather than the mac dylib.

mistial@Mistials-MacBook-Pro lib % cd /Library/sc-hsm-pkcs11/bin
mistial@Mistials-MacBook-Pro bin % ./sc-hsm-pkcs11-test 
PKCS11 unit test running.
dlopen failed with dlopen(/usr/local/lib/libsc-hsm-pkcs11.so, 0x0002): tried: '/usr/local/lib/libsc-hsm-pkcs11.so' (no such file), '/usr/lib/libsc-hsm-pkcs11.so' (no such file)
mistial@Mistials-MacBook-Pro bin %
mistial-dev commented 2 years ago

The relevant code...

#ifndef _WIN32
#define P11LIBNAME "/usr/local/lib/libsc-hsm-pkcs11.so"
#endif
char *p11libname = P11LIBNAME;
dlhandle = dlopen(p11libname, RTLD_NOW);

The dlopen function appears to work fine on mac, as a symbolic link causes the app to pass its unit tests.

mistial@Mistials-MacBook-Pro bin % sudo ln -s /Library/sc-hsm-pkcs11/lib/sc-hsm-pkcs11.dylib /usr/local/lib/libsc-hsm-pkcs11.so
Password:
mistial@Mistials-MacBook-Pro bin % ./sc-hsm-pkcs11-test                                                                   
PKCS11 unit test running.
Calling C_GetFunctionList Calling C_Initialize - CKR_OK : Passed
Calling C_GetInfo - CKR_OK : Passed
Calling C_GetSlotList - CKR_OK : Passed
Calling C_Finalize - CKR_OK : Passed
Unit test finished.
4 tests performed.
0 tests failed.
CardContact commented 2 years ago

You can specify the location of the shared object, dll or dylib using the --module command line argument.