I came across Hyperledger fabric client which has methods/functions to authenticate new members into blockchain network. But I am not sure how I can authenticate new users into a channel in blockchain network.
Can i use channel configuration(configtx) in hyperledger fabric to invite/register new participants into a channel?
Link to channel configuration :http://hyperledger-fabric.readthedocs.io/en/latest/configtx.html#channel-creation
you can use fabric-ca. Fabric-ca provides several apis for user management. You may register, revoke, enroll, reenroll users by fabric-ca. And the documents for fabric-ca is here.
After you setup your fabric-ca server, you can interactive with fabric-ca server with SDK (currently node-sdk and java-sdk) or fabric-ca client. A sample for java-sdk is here. A sample for node-sdk is here.
And on chaincode side, you can read the cert when each time the user call invoke or query from client. The following is a sample code.
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)
}
来源:https://stackoverflow.com/questions/43527599/how-are-new-participants-authenticated-into-a-channel-in-hyperledger-fabric