Seafoodair / neublockchain

Apache License 2.0
6 stars 0 forks source link

SoftHsm2 更换 #2

Closed Seafoodair closed 1 year ago

Seafoodair commented 1 year ago

Install :sudo apt install libsofthsm2

Seafoodair commented 1 year ago

查看安装到什么位置:dpkg -L softhsm2 查阅资料发现在/usr/share/ 文件夹下。 softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432 --token=/var/lib/softhsm2/tokens/ sudo find / -name libsofthsm2.so

生成了token 然后需要配置环境变量。

Seafoodair commented 1 year ago

这一块暂时不需要:请忽略 openssl pkcs12 -export \ -in crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem \ -inkey crypto-config/peerOrganizations/org1.example.com/ca/priv_sk \ -out org1.p12 \ -name "Org1 Example Com CA" \ -passout pass:mypassword

验证: openssl pkcs12 -info -in org1.p12 -passin pass:mypassword

Seafoodair commented 1 year ago

编译了CA CA 版本1.4 go 1.16.6 go mod init go mod vendor(可能需要用到go mod tidy)

github.com/mattn/go-sqlite3

sqlite3-binding.c: In function ‘sqlite3SelectNew’: sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr] 128049 | return pNew; | ^~~~ sqlite3-binding.c:128009:10: note: declared here 128009 | Select standin; | ^~~ Built bin/fabric-ca-server

修改方式:export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

使用softhsm2 编译的fabric-ca-server

GO_TAGS=pkcs11 make -B fabric-ca-server 编译成功 在bin中生成了fabric-ca-server

这种方式可能会失败,本人在源码中配置了GO_TAGS=pkcs11然后编译 make clean make fabric-ca-server make fabric-ca-client 编译成功的二进制文件在bin目录下。 我已经打包了编译成功的二进制文件,连接如下:链接:https://pan.baidu.com/s/1ti3dV1iYNARnBWRZAQ35Nw?pwd=food 提取码:food

Seafoodair commented 1 year ago

使用编译dockers 操作如下: 暂时还没成功,一直报找不倒BCCSP 没有提供者pkcs11