Mac 使用 softhsm

Mac 使用 softhsm

卸载

由于 brew 安装 softhsm 使用的是 boringssl,java 使用通过 JSP 调用 softhsm 会报如下的错误。

text 复制代码
Assertion failed: (ret == 0), function digest_final, file boringssl_crypto_digests.m, line 41.

我们需要卸载已安装的 softhsm(如果是通过 brew 安装的话)。

shell 复制代码
brew unistall softhsm

注意: 我们 jar 程序会引用 /opt/homebrew/lib/softhsm/libsofthsm2.so,卸载后此路径会失效,所以需要重新链接。

安装必要依赖

shell 复制代码
brew install automake libtool pkg-config cppunit openssl

编译 softhsm

请在本地合理安排位置,将 https://github.com/softhsm/SoftHSMv2 进行 clone,分支默认 develop 即可。

shell 复制代码
git clone git@github.com:softhsm/SoftHSMv2.git
cd SoftHSMv2
./autogen.sh
./configure --with-openssl=$(brew --prefix openssl)
make
sudo make install

注意:自行编译后,所需依赖位置: /usr/local/lib/softhsm/libsofthsm2.so

(可选)链接

注意: 我们 jar 程序会引用 /opt/homebrew/lib/softhsm/libsofthsm2.so,卸载后此路径会失效,所以需要重新链接。

ln -s [源文件或目录] [目标文件或目录]

shell 复制代码
mkdir -p /opt/homebrew/lib/softhsm/
ln -s /usr/local/lib/softhsm /opt/homebrew/lib

生成 slot

shell 复制代码
softhsm2-util --init-token --slot 0 --label test --pin 123456 --so-pin 123456

在 java 上使用 JSP 以 PKCS11 协议加载 softhsm。

text 复制代码
--
name = SoftHSM
library = /opt/homebrew/lib/softhsm/libsofthsm2.so
slot = {SLOT}
attributes(generate, *, *) = {
    CKA_TOKEN = true
}
attributes(generate, CKO_CERTIFICATE, *) = {
    CKA_PRIVATE = false
}
attributes(generate, CKO_PUBLIC_KEY, *) = {
    CKA_PRIVATE = false
}
destroyTokenAfterLogout = false
cleaner.shortInterval = 2000
cleaner.longInterval = 60000

ref

相关推荐
pe7er2 天前
macOS 应用无法打开(权限问题)解决方案
macos·mac
harmful_sheep5 天前
mac生效的终端查看
macos
iOS门童5 天前
macOS 应用"已损坏"无法打开?一文搞懂 Gatekeeper 与解决方案
macos
NPE~6 天前
[工具分享]Maccy —— 优雅的 macOS 剪贴板历史管理工具
macos·教程·工具·实用工具
差不多程序员6 天前
Mac安装OpenClaw-cn保姆级教程
macos
dzl843946 天前
mac 安装python
开发语言·python·macos
Bruce_Liuxiaowei6 天前
在 macOS 上通过 Docker 本地安装 OpenClaw 完整教程
macos·docker·容器·openclaw
阿捏利6 天前
详解Mach-O(十五)Mach-O __DATA_CONST
macos·ios·c/c++·mach-o
ShikiSuen6 天前
macOS 的 CpLk 中英切换卡顿的元凶在 InputMethodKit 本身
macos
xiayutian_c6 天前
如虎添翼-MacOS
macos