[英]java complains on loading pkcs dll from softhsm
我正在嘗試使用java 1.8-64bit為我的項目使用softhsm。
我正在嘗試使用此處給出的第一個示例java類連接到SoftHSM java代碼
我能夠安裝softhsm softhsm2-windows安裝程序 。
並且還能夠創建令牌usng softhsm-util.exe工具。
但是當我嘗試運行我得到的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
即使文件在異常位置提供正確的位置。
請幫忙解決這個問題。
已安裝更新的系統Visual C ++:
TLDR :如果要從JAVA應用程序使用softhsm2-x64.dll
,則需要為Visual Studio 2015安裝64位版本的Visual C ++ Redistributable 。
詳細解答 :您使用SoftHSM2安裝程序為MS Windows安裝了SoftHSM。
所有可執行文件和庫存在於該包裝(包括softhsm2-util.exe
)是32位期待softhsm2-x64.dll
其為64位的。
該軟件包中包含的所有可執行文件和庫(包括softhsm2-util.exe
)都依賴於Visual Studio 2015的32位版本Visual C ++ Redistributable對softhsm2-x64.dll
期望,這取決於Visual C ++ Redistributable for Visual的64位版本2015年工作室。
項目網站上的README.md說:
這些軟件包包括32位和64位版本的PKCS#11庫,並且要求在目標系統上安裝32位和64位版本的Visual C ++ Redistributable for Visual Studio 2015 。
安裝后顯示的README.txt說:
該軟件包包括靜態鏈接到OpenSSL 1.1.0d的32位和64位版本的SoftHSM 2.2.0。 它需要在目標系統上安裝32位和64位版本的Visual C ++ Redistributable for Visual Studio 2015。 這些可以從以下網址下載:
http://www.microsoft.com/en-us/download/details.aspx?id=48145
我的建議:為Visual Studio 2015安裝32位和64位版本的Visual C ++ Redistributable。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.