本文介绍了如何安装JCE Provider。
前提条件
密码机实例处于初始化状态并且已创建一个加密用户(CU)。具体操作,请参见快速入门。
已启动HSM客户端(hsm_proxy)。具体操作,请参见启动HSM客户端(hsm_proxy)。
JDK版本为1.8。
操作步骤
下载并安装JCE Provider。
操作系统
说明
CentOS 8
执行以下命令安装JCE Provider。
sudo rpm -ivh ./hsm-client-jce-v2.03.15.10-2.el8.x86_64.rpm
Debian
访问hsm-client-jce-2.03.15.10-20240710_1.x86_64.deb,下载JCE Provider安装包。
执行以下命令安装JCE Provider。
sudo dpkg -i hsm-client-jce-2.03.15.10-20240710_1.x86_64.deb
查看是否安装成功。
如果能找到如下所有文件,表示安装成功。
/opt/hsm/java/caviumjca-1.0.0-jar-with-dependencies.jar
/opt/hsm/java/hamcrest-core-1.3.jar
/opt/hsm/java/junit-4.12.jar
/opt/hsm/java/hsm-test-1.0.0.jar
/opt/hsm/java/log4j-api-2.17.0.jar
/opt/hsm/java/log4j-core-2.17.0.jar
/opt/hsm/lib/libcaviumjca.so
安装验证
使用CU用户的信息设置应用程序中的环境变量。
说明请将
user name
和password
替换为CU用户的用户名和密码。export LD_LIBRARY_PATH=/opt/hsm/lib export HSM_PARTITION=PARTITION_1 export HSM_USER=user name export HSM_PASSWORD=password
验证JCE Provider基本功能。
java -classpath "/opt/hsm/java/*" org.junit.runner.JUnitCore TestBasicFunctionality
如果操作成功,预期输出:
JUnit version 4.12 .2021-03-12 13:56:40,527 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:33) - Adding provider. 2021-03-12 13:56:40,721 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:42) - Logging in. 2021-03-12 13:56:40,721 INFO [main] cfm2.LoginManager (LoginManager.java:244) - Looking for credentials in HsmCredentials.properties 2021-03-12 13:56:40,722 INFO [main] cfm2.LoginManager (LoginManager.java:262) - Looking for credentials in System.properties 2021-03-12 13:56:40,722 INFO [main] cfm2.LoginManager (LoginManager.java:270) - Looking for credentials in System.env 2021-03-12 13:56:40,750 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:54) - Generating AES Key with key size 256. 2021-03-12 13:56:40,765 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:63) - Encrypting with AES Key. 2021-03-12 13:56:40,813 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:84) - Deleting AES Key. 2021-03-12 13:56:40,816 DEBUG [main] TestBasicFunctionality (TestBasicFunctionality.java:92) - Logging out. Time: 0.328 OK (1 test)