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系列

相关推荐
2601_961875243 天前
决战申论100题2026|最新|范文
linux·容器·centos·debian·ssh·fabric·vagrant
EMQX3 天前
跨越 OT 与 IT 的鸿沟:15 分钟实现 NeuronEX 与 Azure Fabric 联动
mqtt·fabric·neuronex
Legend NO248 天前
从数据中台到 Data Fabric:数据价值落地,终究要回归本质(二)
大数据·运维·fabric
安当加密10 天前
汽车密钥管理:从“一把钥匙开所有门“到“一车一密“的进化之路
kms·hsm·v2x·汽车网络安全·车联网安全·secoc·汽车密钥管理
安当加密14 天前
汽车密钥管理系统怎么设计?从HSM到云端KMS的完整架构方案
国密·kms·hsm·密钥管理·汽车安全
Tim风声(网络工程师)1 个月前
iMaster NCE-Campus和iMaster NCE-Fabric的区别
运维·fabric
宝桥南山2 个月前
Microsoft Fabric - 尝试一下使用Shortcut Transformation进行数据同步
microsoft·ai·微软·database·powerbi·fabric
开开心心就好2 个月前
体积小巧的图片重复查找工具推荐
linux·运维·服务器·智能手机·自动化·excel·fabric
无忧智库2 个月前
从数据孤岛到全球实时协同:某跨国企业 Data Fabric 供应链数据编织平台全解析(WORD)
运维·fabric
搬砖魁首2 个月前
Fabric系列 - HSM之3 区块链上的结合
区块链·php·fabric·长安链·hsm