码:
String pkcs11cfg = "pkcs11.cfg";
Provider p = new SunPKCS11(pkcs11cfg);
Security.addProvider(p);
KeyStore ks = KeyStore.getInstance("PKCS11", p);
ks.load(null, pin);
System.out.println(ks.size()); // prints 0
Run Code Online (Sandbox Code Playgroud)
CFG:
name = pkcs11Test
library = /usr/local/lib/libsofthsm.so
slot = 1
Run Code Online (Sandbox Code Playgroud)
问题是我有一些密钥对,我用pkcs11-tool添加它们.
softhsm的版本是1.2.1
为什么KeyStore中没有任何别名?如何解决这个问题?
我目前正在尝试使用 SoftHSM(在 Windows 平台上)。目标是在客户端和 HSM 服务器之间建立通信通道,以便可以在服务器端加密一些数据并发送回调用客户端。
我从这个站点下载了一个:https : //www.opendnssec.org/download/
此外,我按照本页所述的文档进行操作:https : //wiki.opendnssec.org/display/SoftHSMDOCS/SoftHSM+Documentation+Home - 但除了创建几个插槽之外,我还没有做对任何事情.
我运行以下命令来创建插槽:
softhsm --init-token --slot 0 --label "My token 1"
Run Code Online (Sandbox Code Playgroud)
我不确定如何从这里开始,我找不到有关该主题的任何有用信息/教程。我想我应该从小处着手,尝试创建一个与 SoftHSM 通信的服务器应用程序......我为所有 n00b 问题道歉!
我正在尝试从此处安装 SoftHSMv2 。
在构建 SoftHSM 之前,我需要在 Windows 10 上的 git bash 上安装 GNU Autotools,例如 automake、autoconf、libtool 和 pkg-config。从我获得这些工具的地方,我尝试了 cygwin,但之后我遇到了依赖错误构建 SoftHSMv2
我试图安装SoftHSM如图所示这里,这需要OpenSSL的.所以,我安装了OpenSSL v1.0.2j,但似乎它并没有捆绑GOST支持,或至少我找不到libgost.so的/usr/lib/openssl/engines; 所以我从我发现的旧版OpenSSL(v1.0.0k-2.1.x86_64)中取出它并将其放在该文件夹中.
然后,正如多个论坛所建议的那样,我修改了openssl.cnf(in /usr/local/ssl)文件.
在RANDFIL = $ENV::HOME/.rnd我添加后的行中:
openssl_conf=openssl_def
Run Code Online (Sandbox Code Playgroud)
在文件的末尾:
# OpenSSL default section
[openssl_def]
engines = engine_section
# Engine section
[engine_section]
gost = gost_section
# Engine gost section
[gost_section]
engine_id = gost
dynamic_path = /usr/lib/openssl/engines/libgost.so
default_algorithms = ALL
CRYPT_PARAMS = id-Gost28147-89-CryptoPro-A-ParamSet
Run Code Online (Sandbox Code Playgroud)
但仍处于SoftHSM安装的配置阶段,它显示以下错误:
checking for OpenSSL GOST support... Cannot GOST engine
configure: error: OpenSSL library has no GOST support
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感谢!
如果我运行此命令:openssl ciphers|tr ':' '\n'|grep GOST,输出为:Error configuring …
在以非 root 用户身份通过 softhsm2-util 初始化令牌时,我收到以下错误:
$ softhsm2-util --init-token --slot 0 --label "test" --so-pin 5462 --pin 8764329
ERROR: Could not initialize the library.
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我正在尝试在 SoftHSM 2 上进行 POC,但我遇到了以下问题。
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:50)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_SLOT_ID_INVALID
at sun.security.pkcs11.wrapper.PKCS11.C_GetSlotInfo(Native Method)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:365)
... 2 more
Run Code Online (Sandbox Code Playgroud)
HSM 配置文件:
# SoftHSM v2 configuration file
name= SoftHSM2
library = C:\SoftHSM2\lib\softhsm2-x64.dll
slot=1
Run Code Online (Sandbox Code Playgroud)
如果我评论 slot=1 ,那么我得到
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:50)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_TOKEN_NOT_RECOGNIZED
at sun.security.pkcs11.wrapper.PKCS11.C_OpenSession(Native Method)
at sun.security.pkcs11.SessionManager.openSession(SessionManager.java:215)
at sun.security.pkcs11.SessionManager.getOpSession(SessionManager.java:150)
at sun.security.pkcs11.Token.<init>(Token.java:151)
at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:858)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:367)
... 2 more
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它没有变得 …