[英]java complains on loading pkcs dll from softhsm
I am trying to use softhsm for my project using java 1.8-64bit. 我正在尝试使用java 1.8-64bit为我的项目使用softhsm。
I am trying with m first sample java class given here Connecting to SoftHSM java code 我正在尝试使用此处给出的第一个示例java类连接到SoftHSM java代码
I was able to install softhsm softhsm2-windows installer . 我能够安装softhsm softhsm2-windows安装程序 。
And Also able to create token usng softhsm-util.exe tool. 并且还能够创建令牌usng softhsm-util.exe工具。
but when I try to run the java code I am getting 但是当我尝试运行我得到的java代码时
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at SoftHSM.main(SoftHSM.java:44)
Caused by: java.io.IOException: The specified module could not be found.
Z:/SOFTHSM_INSTALL/lib/softhsm2-x64.dll
at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
at sun.security.pkcs11.wrapper.PKCS11.<init>(PKCS11.java:138)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:151)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:313)
... 2 more
Even though the file is available in right location as mentioned in exception. 即使文件在异常位置提供正确的位置。
Please help to solve this issue. 请帮忙解决这个问题。
Updated System Visual C++ installed: 已安装更新的系统Visual C ++:
TLDR : If you want to use softhsm2-x64.dll
from your JAVA application then you need to install 64-bit version of Visual C++ Redistributable for Visual Studio 2015 . TLDR :如果要从JAVA应用程序使用softhsm2-x64.dll
,则需要为Visual Studio 2015安装64位版本的Visual C ++ Redistributable 。
Detailed answer : You did install SoftHSM using SoftHSM2 installer for MS Windows . 详细解答 :您使用SoftHSM2安装程序为MS Windows安装了SoftHSM。
All executables and libraries present in that package (including softhsm2-util.exe
) are 32-bit expect for softhsm2-x64.dll
which is 64-bit. 所有可执行文件和库存在于该包装(包括softhsm2-util.exe
)是32位期待softhsm2-x64.dll
其为64位的。
All executables and libraries present in that package (including softhsm2-util.exe
) depend on 32-bit version of Visual C++ Redistributable for Visual Studio 2015 expect for softhsm2-x64.dll
which depends on 64-bit version of Visual C++ Redistributable for Visual Studio 2015. 该软件包中包含的所有可执行文件和库(包括softhsm2-util.exe
)都依赖于Visual Studio 2015的32位版本Visual C ++ Redistributable对softhsm2-x64.dll
期望,这取决于Visual C ++ Redistributable for Visual的64位版本2015年工作室。
README.md on project website says: 项目网站上的README.md说:
These packages include both 32-bit and 64-bit versions of PKCS#11 library and require both 32-bit and 64-bit version of Visual C++ Redistributable for Visual Studio 2015 to be installed on the target system. 这些软件包包括32位和64位版本的PKCS#11库,并且要求在目标系统上安装32位和64位版本的Visual C ++ Redistributable for Visual Studio 2015 。
README.txt displayed after the installation says: 安装后显示的README.txt说:
This package includes both 32-bit and 64-bit build of SoftHSM 2.2.0 statically linked to OpenSSL 1.1.0d. 该软件包包括静态链接到OpenSSL 1.1.0d的32位和64位版本的SoftHSM 2.2.0。 It requires both 32-bit and 64-bit version of Visual C++ Redistributable for Visual Studio 2015 to be installed on the target system. 它需要在目标系统上安装32位和64位版本的Visual C ++ Redistributable for Visual Studio 2015。 These can be downloaded from: 这些可以从以下网址下载:
http://www.microsoft.com/en-us/download/details.aspx?id=48145 http://www.microsoft.com/en-us/download/details.aspx?id=48145
My advice: install both 32-bit and 64-bit version of Visual C++ Redistributable for Visual Studio 2015. 我的建议:为Visual Studio 2015安装32位和64位版本的Visual C ++ Redistributable。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.