本文介紹了如何安裝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)