diff --git a/core/scc/cscc/configure.go b/core/scc/cscc/configure.go index 31f33358bbc..3fa3926ea16 100644 --- a/core/scc/cscc/configure.go +++ b/core/scc/cscc/configure.go @@ -107,7 +107,14 @@ func (e *PeerConfiger) Invoke(stub shim.ChaincodeStubInterface) pb.Response { case JoinChain: // 2. check local MSP Admins policy if err = e.policyChecker.CheckPolicyNoChannel(mgmt.Admins, sp); err != nil { - return shim.Error(fmt.Sprintf("\"JoinChain\" request failed authorization check for channel [%s]: [%s]", args[1], err)) + cid, e := utils.GetChainIDFromBlockBytes(args[1]) + errorString := fmt.Sprintf("\"JoinChain\" request failed authorization check "+ + "for channel [%s]: [%s]", cid, err) + if e != nil { + errorString = fmt.Sprintf("\"JoinChain\" request failed authorization [%s] and unable "+ + "to extract channel id from the block due to [%s]", err, e) + } + return shim.Error(errorString) } return joinChain(args[1]) @@ -127,7 +134,7 @@ func (e *PeerConfiger) Invoke(stub shim.ChaincodeStubInterface) pb.Response { case GetChannels: // 2. check local MSP Members policy if err = e.policyChecker.CheckPolicyNoChannel(mgmt.Members, sp); err != nil { - return shim.Error(fmt.Sprintf("\"GetChannels\" request failed authorization check for channel [%s]: [%s]", args[1], err)) + return shim.Error(fmt.Sprintf("\"GetChannels\" request failed authorization check: [%s]", err)) } return getChannels() diff --git a/protos/utils/blockutils.go b/protos/utils/blockutils.go index 1388492ffdd..8eb9e16962b 100644 --- a/protos/utils/blockutils.go +++ b/protos/utils/blockutils.go @@ -23,6 +23,16 @@ import ( cb "github.com/hyperledger/fabric/protos/common" ) +// GetChainIDFromBlockBytes returns chain ID given byte array which represents the block +func GetChainIDFromBlockBytes(bytes []byte) (string, error) { + block, err := GetBlockFromBlockBytes(bytes) + if err != nil { + return "", err + } + + return GetChainIDFromBlock(block) +} + // GetChainIDFromBlock returns chain ID in the block func GetChainIDFromBlock(block *cb.Block) (string, error) { if block.Data == nil || block.Data.Data == nil || len(block.Data.Data) == 0 {