Fabric系列 - SoftHSM 软件模拟HSM

在 fabric-ca-server 上使用软件模拟的 HSM(密码卡) 功能

安装 SoftHSMv2

教程 SoftHSMv2

  • 默认的配置文件 /etc/softhsm2.conf
  • 默认的token目录 /var/lib/softhsm/tokens/

初始化和启动fabric-ca-server,需要设置一个管理员用户的名称和密码

初始化令牌

bash 复制代码
# 初始化一个即可
softhsm2-util --init-token --slot 0 --label "fabric"
	
	=== SO PIN (4-255 characters) ===
	Please enter SO PIN: 71811222
	Please reenter SO PIN: 71811222
	=== User PIN (4-255 characters) ===
	Please enter user PIN: 71811222
	Please reenter user PIN: 71811222
	The token has been initialized and is reassigned to slot 423405613

softhsm2-util --init-token --slot 1 --label "fabric"
	=== SO PIN (4-255 characters) ===
	Please enter SO PIN: 111111
	Please reenter SO PIN: 111111
	=== User PIN (4-255 characters) ===
	Please enter user PIN: 222222
	Please reenter user PIN: 222222
	The token has been initialized and is reassigned to slot 121977387


	#查看
	softhsm2-util --show-slots

配置fabric-ca-server的配置文件fabric-ca-server-config.yaml

yaml 复制代码
bccsp:
    default: PKCS11
    sw:
        hash: SHA2
        security: 256
        filekeystore:
            keystore: msp/keystore
    pkcs11:
        Library: /usr/local/lib/softhsm/libsofthsm2.so
        Pin: "222222"
        Label: fabric
        hash: SHA2
        security: 256
        Immutable: false

启动 fabric-ca-server

bash 复制代码
#模式一: 新创建证书, 再启动  (私钥会保管在HSM中)
rm ./config-hsm/ca-cert.pem
fabric-ca-server init -b admin:adminpw -H config-hsm

fabric-ca-server start -b admin:adminpw -H config-hsm

#模式二: 指定已事先生成好的证书目录
fabric-ca-server start -b admin:adminpw -H /etc/hyperledger/fabric-ca-server-config

查看 fabric-ca-server.db

bash 复制代码
sudo apt-get install sqlite3
sqlite3 config-hsm\fabric-ca-server.db
sqlite> .tables
# 查用户表 (用户admin已经在数据库里。这是Fabric CA启动时生成的)
sqlite> select * from users;
# 使用 enroll 命令登记admin后,才会生成证书
sqlite> select * from certificates;

: 区块链知识系列
: 密码学系列
: 零知识证明系列
: 共识系列
: 公链调研系列
: BTC系列
: 以太坊系列
: EOS系列
: Filecoin系列
: 联盟链系列
: Fabric系列
: 智能合约系列
: Token系列

相关推荐
花 满 楼4 小时前
HSM自学之路——阶段 1 密码学算法分类与原理
嵌入式·hsm
宝桥南山3 天前
Microsoft Fabric - 简单尝试一下Microsoft Fabric .NET SDK
microsoft·微软·.net·.netcore·powerbi·fabric
安当加密03015 天前
政务电子签章密钥安全:HSM私钥保护与泄露应急响应
hsm·电子签章·密钥管理·电子签名法·政务安全
NGINX开源社区9 天前
NGINX Gateway Fabric 2.6:F5 WAF for NGINX 集成 Gateway API
nginx·gateway·fabric
安当加密030110 天前
PCI DSS 4.0与SWIFT CSP双合规:银行收单与跨境支付HSM部署实战
swift·hsm·密钥管理·pci dss·双合规
漫谈数据智理12 天前
主动元数据为何是数据编织的核心——从“连接数据”走向“感知、理解与行动”的 Data Fabric
运维·fabric
不爱吃糖的程序媛13 天前
React Native 三方库鸿蒙适配实战:react-native-emoji-popup(Fabric 自定义组件)从 0 到 1
react native·harmonyos·fabric
编码者卢布16 天前
【Azure Fabric Service】Service Fabric 节点 Error:数据盘挂载失败与 CHKDSK 修复
microsoft·azure·fabric
Eloudy17 天前
全文 - 第1部分 - NVIDIA Fabric Manager User Guide
gpu·fabric·超节点
宝桥南山22 天前
GitHub Copilot - 尝试配置和使用一下Microsoft Fabric Core MCP Server
运维·microsoft·ai·微软·powerbi·fabric