Open 1oh1 opened 2 days ago
On a Raspberry Pi 5 running 64-bit OS, I followed the INSTALL guide on libp11-0.4.12 and see a similar error:
$ openssl engine -t -vv
(dynamic) Dynamic engine loading support
[ unavailable ]
SO_PATH: Specifies the path to the new ENGINE shared library
NO_VCHECK: Specifies to continue even if version checking fails (boolean)
ID: Specifies an ENGINE id name for loading
LIST_ADD: Whether to add a loaded ENGINE to the internal list (0=no,1=yes,2=mandatory)
DIR_LOAD: Specifies whether to load from 'DIR_ADD' directories (0=no,1=yes,2=mandatory)
DIR_ADD: Adds a directory from which ENGINEs can be loaded
LOAD: Load up the ENGINE specified by other settings
(pkcs11) pkcs11 engine
[ available ]
SO_PATH: Specifies the path to the 'pkcs11' engine shared library
MODULE_PATH: Specifies the path to the PKCS#11 module shared library
PIN: Specifies the pin code
VERBOSE: Print additional details
QUIET: Remove additional details
INIT_ARGS: Specifies additional initialization arguments to the PKCS#11 module
FORCE_LOGIN: Force login to the PKCS#11 module
RE_ENUMERATE: re enumerate slots
$ openssl version -a
OpenSSL 3.0.15 3 Sep 2024 (Library: OpenSSL 3.0.15 3 Sep 2024)
built on: Wed Nov 6 12:37:33 2024 UTC
platform: debian-arm64
options: bn(64,64)
compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -fzero-call-used-regs=used-gpr -DOPENSSL_TLS_SECURITY_LEVEL=2 -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-D6U5M7/openssl-3.0.15=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/aarch64-linux-gnu/engines-3"
MODULESDIR: "/usr/lib/aarch64-linux-gnu/ossl-modules"
Seeding source: os-specific
CPUINFO: OPENSSL_armcap=0xbd
$ openssl engine dynamic -pre SO_PATH:"/usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so" -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -post MODULE_PATH:"/usr/local/lib/libp11.so" -t
(dynamic) Dynamic engine loading support
[Success]: SO_PATH:/usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so
[Success]: ID:pkcs11
[Success]: LIST_ADD:1
[Failure]: LOAD
40401B19FF7F0000:error:1300006D:engine routines:dynamic_load:init failed:../crypto/engine/eng_dyn.c:514:
[ unavailable ]
I added this to the end of /etc/ssl/openssl.cnf
is:
openssl_conf = openssl_init
[openssl_init]
engines = engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
engine_id = pkcs11
dynamic_path = /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so
MODULE_PATH = /usr/local/lib/libp11.so
init = 0
PIN=111111
Some other things I've tried:
$ strings /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so | grep 'bind_engine'
bind_engine
bind_engine
bind_engine
$ file /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so
/usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2907ee0b8a2a8df5e0d483d4aa1dbe8271366d1a, with debug_info, not stripped
$ ls -alh /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so
-rwxr-xr-x 1 root root 406K Dec 2 01:15 /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so
$ strings /usr/local/lib/libp11.so | grep 'GetFunctionList'
C_GetFunctionList
CK_C_GetFunctionList
$ file /usr/local/lib/libp11.so.3.5.0
/usr/local/lib/libp11.so.3.5.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b74ea3a37724fa7df823f4d45a369da2f50a1a30, with debug_info, not stripped
$ ls -alh /usr/local/lib/libp11.so
lrwxrwxrwx 1 root root 15 Dec 2 01:15 /usr/local/lib/libp11.so -> libp11.so.3.5.0
$ openssl req -engine pkcs11 -new -key 0:1 -keyform engine -out cert.pem -text -x509 -days 365
Engine "pkcs11" set.
/usr/local/lib/libp11.so: undefined symbol: C_GetFunctionList
Unable to load module /usr/local/lib/libp11.so
PKCS11_get_private_key returned NULL
Could not read private key from org.openssl.engine:pkcs11:0:1
40409EAAFF7F0000:error:41000401:libp11:ERR_P11_error:Unable to load PKCS#11 module:p11_load.c:77:
40409EAAFF7F0000:error:40000067:pkcs11 engine:ERR_ENG_error:invalid parameter:eng_back.c:603:
40409EAAFF7F0000:error:13000080:engine routines:ENGINE_load_private_key:failed loading private key:../crypto/engine/eng_pkey.c:79:
$ openssl req -engine pkcs11 -new -key 0:1 -keyform engine -passin pass:111111 -out cert.pem -text -x509 -days 365
Engine "pkcs11" set.
/usr/local/lib/libp11.so: undefined symbol: C_GetFunctionList
Unable to load module /usr/local/lib/libp11.so
PKCS11_get_private_key returned NULL
Could not read private key from org.openssl.engine:pkcs11:0:1
4040E376FF7F0000:error:41000401:libp11:ERR_P11_error:Unable to load PKCS#11 module:p11_load.c:77:
4040E376FF7F0000:error:40000067:pkcs11 engine:ERR_ENG_error:invalid parameter:eng_back.c:603:
4040E376FF7F0000:error:13000080:engine routines:ENGINE_load_private_key:failed loading private key:../crypto/engine/eng_pkey.c:79:
$ pkcs11-tool --module /usr/local/lib/libp11.so -O
error: Failed to load pkcs11 module
Aborting.
$ pkcs11-tool --module /usr/lib/aarch64-linux-gnu/engines-3/pkcs11.so -O
error: Failed to load pkcs11 module
Aborting.
Very similar to https://github.com/OpenSC/libp11/issues/542
How do I use
openssl req -engine pkcs11 -new -key 0:1 -keyform engine -out cert.pem -text -x509 -days 365
to generate a certificate and sign it using the private key stored on the pkcs#11 token?I have compiled 64 and 32-bit versions of libp11 and verified that they have the right exports and imports:
I installed FireDaemon OpenSSL (64-bit version) and tried this command:
But I don't know what I should add to
C:\Program Files\Common Files\FireDaemon SSL 3\openssl.cnf
so that the pkcs11 engine is loaded each time. I've added this to the end but that doesn't seem to be working:The key already exists on the token and I tested it with
pkcs11-tool --test --login --pin 111111
as well: