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

相关推荐
CC码码4 天前
迈向开源第一步,给fabric.js提PR
前端·javascript·开源·web·fabric
testpassportcn7 天前
微軟 DP-600 認證介紹|Microsoft Fabric Analytics Engineer Associate 完整解析與考試攻略
运维·fabric
peihexian9 天前
ingress-nginx更换为f5 nginx gateway fabric
nginx·gateway·fabric
一个处女座的程序猿10 天前
LLMs之Prompt:Fabric的简介、安装和使用方法、案例应用之详细攻略
llm·prompt·fabric
添加shujuqudong1如果未回复21 天前
基于S-S或LCC-S结构的WPT无线电能传输电路模型,采用输出电压闭环PI控制。 另附带电路...
fabric
友莘居士22 天前
Hyperledger Fabric与 FISCO BCOS深度对比
区块链·fabric·fisco
kaozhengpro22 天前
Microsoft DP-700 考試戰報|Fabric 資料工程師一次通過心得
运维·microsoft·fabric
TFATS22 天前
Nvidia H100 算力服务器 Cuda Fabric Manager 升级
服务器·postgresql·fabric
563471794124 天前
分布式驱动电动汽车路面附着系数估计:无迹卡尔曼与容积卡尔曼滤波大比拼
fabric
二狗哈25 天前
Cesium快速入门22:fabric自定义着色器
运维·开发语言·前端·webgl·fabric·cesium·着色器