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

相关推荐
星辰即远方19 小时前
天气预报总结
macos·ios·objective-c·cocoa
xixiaoyunya20 小时前
Mac远程访问新范式:基于80KM穿云箭的内网穿透技术实践
macos
秋雨梧桐叶落莳21 小时前
计算器仿写总结
学习·macos·ios·objective-c·cocoa
寒水馨1 天前
macOS下载、安装uv-0.12.0(附安装包uv-aarch64-apple-darwin.tar.gz)
python·macos·rust·项目管理·包管理器·astral·pip替代
寒水馨1 天前
macOS下载、安装protobuf-v35.1(附安装包protoc-35.1-osx-universal_binary.zip)
macos·google·grpc·序列化·protobuf·protoc·数据交换
寒水馨1 天前
macOS下载、安装ripgrep-15.2.0(附安装包ripgrep-15.2.0-aarch64-apple-darwin.tar.gz)
macos·正则表达式·rust·ripgrep·rg·命令行搜索·代码搜索
起司喵喵2 天前
Flutter-MacOS桌面OS系统|flutter.+window_manager客户端OS模板
flutter·macos·策略模式
代码对我眨眼睛2 天前
macOS Google Chrome 常用快捷键
前端·chrome·macos
啊真真真2 天前
macOS下libnfc ..写卡失败问题及解决方案
macos·策略模式
叶 落2 天前
Mac 通过 Miniconda 安装 Python
python·macos·conda·miniconda