Dll PKCS11 Windows无效引擎YubiHSM2
又是我。 我正在使用YubiHSM2 HSM模块,我正在尝试将其设置为使用pkcs11引擎,这将允许我在HSM中使用OpenSSL 我在Windows上实现这个,这给我带来了很多麻烦。 我已经安装了OpenSSL 32,64、OpenSC、YubiHSM2驱动程序以及libp11(使用MSYS2构建) 我的OpenSSL.cnf中有趣的部分如下所示:Dll PKCS11 Windows无效引擎YubiHSM2,dll,openssl,pkcs#11,opensc,yubico,Dll,Openssl,Pkcs#11,Opensc,Yubico,又是我。 我正在使用YubiHSM2 HSM模块,我正在尝试将其设置为使用pkcs11引擎,这将允许我在HSM中使用OpenSSL 我在Windows上实现这个,这给我带来了很多麻烦。 我已经安装了OpenSSL 32,64、OpenSC、YubiHSM2驱动程序以及libp11(使用MSYS2构建) 我的OpenSSL.cnf中有趣的部分如下所示: openssl_conf = openssl_init [openssl_init] engines = engine_section [en
openssl_conf = openssl_init
[openssl_init]
engines = engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
engine_id = pkcs11
dynamic_path = "C:\Windows\System32\opensc-pkcs11.dll"
MODULE_path = "C:\Users\myUser\Desktop\SecureTemial\yubihsm2-sdk\bin\yubihsm_pkcs11.dll"
PIN = "0001password"
init = 0
当我尝试时:
C:\OpenSSL-Win64\bin\openssl.exe req -new -x509 -days 365 -sha256 -config C:\Users\myUser\Desktop\SecureTemial\openssl.cnf -engine pkcs11 -keyform engine -key slot_0-label_my_key -out cert.pem
我收到以下消息:
C:\OpenSSL-Win64\bin\openssl.exe : invalid engine "pkcs11"
In Zeile:1 Zeichen:2
+ C:\OpenSSL-Win64\bin\openssl.exe req -new -x509 -days 365 -sha256 -c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (invalid engine "pkcs11":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
16056:error:25078067:DSO support routines:win32_load:could not load the shared
library:crypto\dso\dso_win32.c:106:filename(C:\Program Files\OpenSSL\lib\engines-1_1\pkcs11.dll)
16056:error:25070067:DSO support routines:DSO_load:could not load the shared library:crypto\dso\dso_lib.c:161:
16056:error:260B6084:engine routines:dynamic_load:dso not found:crypto\engine\eng_dyn.c:414:
16056:error:2606A074:engine routines:ENGINE_by_id:no such engine:crypto\engine\eng_list.c:339:id=pkcs11
16056:error:25078067:DSO support routines:win32_load:could not load the shared
library:crypto\dso\dso_win32.c:106:filename(pkcs11.dll)
16056:error:25070067:DSO support routines:DSO_load:could not load the shared library:crypto\dso\dso_lib.c:161:
16056:error:260B6084:engine routines:dynamic_load:dso not found:crypto\engine\eng_dyn.c:414:
Error configuring OpenSSL modules
16056:error:25078067:DSO support routines:win32_load:could not load the shared
library:crypto\dso\dso_win32.c:106:filename(C:WindowsSystem32opensc-pkcs11.dll)
16056:error:25070067:DSO support routines:DSO_load:could not load the shared library:crypto\dso\dso_lib.c:161:
16056:error:260B6084:engine routines:dynamic_load:dso not found:crypto\engine\eng_dyn.c:414:
16056:error:260BC066:engine routines:int_engine_configure:engine configuration
error:crypto\engine\eng_cnf.c:141:section=pkcs11_section, name=dynamic_path, value=C:WindowsSystem32opensc-pkcs11.dll
16056:error:0E07606D:configuration file routines:module_run:module initialization
error:crypto\conf\conf_mod.c:173:module=engines, value=engine_section, retcode=-1
我已经检查了dll是否被锁定并以管理员身份运行等。
如果你有任何线索是什么造成了这里的麻烦,请让我知道
多谢各位 这个问题是我在对类似主题进行研究时,搜索结果中出现的第一个问题之一。由于还没有答案,我将概述我的解决方案的结果: 要将的PKCS#11引擎与OpenSSL一起使用,必须将其编译为动态引擎,并与您正在使用的OpenSSL版本进行静态链接。当您使用时(根据您在问题中提到的安装目录,这是一个很好的猜测),使用从第三方资源获得的MSYS2版本可能不起作用,使用OpenSC项目附带的PKCS#11库也不起作用 幸运的是,Shining Light Productions的OpenSSL版本附带了所有必需的库,因此您可以轻松地自己编译libp11,例如使用(按照链接查看如何获取它以及如何正确设置命令行以供使用):
C:\OpenSSL-Win32
或C:\OpenSSL-Win64
)-libp11的makefile需要这些文件夹作为其绑定BUILD\u。跑
set BUILD_FOR=WIN64
在您的命令行上
NMAKE /F Makefile.mak
src
文件夹中有两个新库:libp11.dll
和pkcs11.dll
。后者是用于OpenSSL的PKCS#11引擎。将其复制到例如Windows libraries文件夹中(对于32位版本,System32
,对于x64版本,SysWOW64
)openssl.cnf
文件。抄袭
openssl_conf = openssl_init
到文件的开头,其余部分到文件的结尾:
[openssl_init]
engines = engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
dynamic_path = "C:\\Windows\\SysWOW64\\pkcs11.dll"
module_path = "C:\\Users\\myUser\\Desktop\\SecureTemial\\yubihsm2-sdk\\bin\\yubihsm_pkcs11.dll"
PIN = "0001password"
openssl.cnf
文件。OpenSSL安装附带了几个示例文件。默认情况下,对于x64版本,上述二进制文件的配置文件位置为C:\Program files\Common files\SSL\openssl.cnf
;对于x86版本,上述二进制文件的配置文件位置为C:\Program files(x86)\Common files\SSL\openssl.cnf
。但是您系统上的其他OpenSSL安装(例如,来自OpenVPN、MingW、MSYS2以及与捆绑OpenSSL一起提供的类似产品)可能会干扰设置文件位置。通过相应地设置OPENSSL\u CONF
环境变量,可以确保使用正确的设置文件\\
而不是\
正确地转义反斜杠openssl.cnf的[pkcs11\u部分]
中的引擎id
和init
部分