[英]How are new participants authenticated into a channel in hyperledger fabric
我遇到了Hyperledger Fabric客戶端,該客戶端具有將新成員認證為區塊鏈網絡的方法/功能。 但是我不確定如何才能在區塊鏈網絡的通道中對新用戶進行身份驗證。
我可以在超級賬本結構中使用頻道配置(configtx)邀請/將新參與者注冊到頻道嗎?
鏈接到通道配置: http : //hyperledger-fabric.readthedocs.io/en/latest/configtx.html#channel-creation
您可以使用fabric-ca。 Fabric-ca提供了幾種用於用戶管理的API。 您可以通過fabric-ca注冊,撤銷,注冊或重新注冊用戶。 關於fabric-ca的文件在這里 。
設置fabric-ca服務器后,您可以使用SDK(當前為node-sdk和java-sdk)或fabric-ca客戶端與fabric-ca服務器進行交互。 這里是java-sdk的示例。 這里是node-sdk的示例。
在鏈碼方面,每次用戶調用從客戶端調用或查詢時,您都可以讀取證書。 以下是示例代碼。
import(
"crypto/x509"
"encoding/pem"
"bytes"
"strings"
"github.com/hyperledger/fabric/core/chaincode/shim"
)
func parseCert(stub){
creator, err := identityService.Stub.GetCreator()
if err != nil {
logger.Debug("Error received on GetCreator", err)
vm.PushErrorObjectVa(duktape.ErrError, "%s", err.Error())
vm.Throw()
return
}
certStart := bytes.IndexAny(creator, "----BEGIN CERTIFICATE-----")
if certStart == -1 {
logger.Debug("No certificate found")
return
}
certText := creator[certStart:]
block, _ := pem.Decode(certText)
if block == nil {
logger.Debug("Error received on pem.Decode of certificate", certText)
return
}
ucert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
logger.Debug("Error received on ParseCertificate", err)
return
}
logger.Debug("Common Name", ucert.Subject.CommonName)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.