1

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

skr
  • 127
  • 2
  • 16

1 Answers1

4

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)

}
zhaochy
  • 734
  • 7
  • 12
  • thanks for the informative answer. unfortunately the links have expired. could you point in a direction for similar ca-server docs / specifically getCreator (I called with two different certificates and they returned the same) thanks! – a.hrdie Nov 09 '18 at 15:12