Hyperledger Fabric:紧急情况:运行时错误:在fabric / peer / common.NewPeerClientForAddress处无效的内存地址或nil指针取消引用

语素

我们正在尝试使用以下命令调用链码:

FABRIC_CFG_PATH=${PWD} CORE_PEER_LOCALMSPID=org1MSP CORE_LOGGING_LEVEL=debug CORE_PEER_TLS_ENABLED=true CORE_PEER_TLS_CLIENTAUTHREQUIRED=true CORE_PEER_MSPCONFIGPATH=msp CORE_PEER_TLS_CLIENTCERT_FILE=user-org1-tls.pem CORE_PEER_TLS_CLIENTKEY_FILE=user-org1-tls.key peer chaincode invoke -C dscsa -n mycc -c '{"Args":["create","00000"]}' -o orderer1-ord:7050 --tls --cafile ord-ca-chain.pem --peerAddresses peer3-org1:7051 --tlsRootCertFiles org1-ca-chain.pem --peerAddresses peer3-org2:7051 --tlsRootCertFiles org2-ca-chain.pem --peerAddresses peer3-org3:7051 --tlsRootCertFiles org3-ca-chain.pem

但是得到这个错误:

2019-03-21 19:04:37.459 UTC [msp] Validate -> DEBU 036 MSP org1MSP validating identity
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x110fddc]

goroutine 1 [running]:
github.com/hyperledger/fabric/peer/common.NewPeerClientForAddress(0x7ffd955fe783, 0x9, 0x7ffd955fe7a0, 0x10, 0x8fb52c, 0x9e8745, 0x14848a7)
    /opt/gopath/src/github.com/hyperledger/fabric/peer/common/peerclient.go:44 +0x8c
github.com/hyperledger/fabric/peer/common.GetEndorserClient(0x7ffd955fe783, 0x9, 0x7ffd955fe7a0, 0x10, 0x4, 0x1, 0xc4205d1988, 0x9e5bec)
    /opt/gopath/src/github.com/hyperledger/fabric/peer/common/peerclient.go:122 +0x56
github.com/hyperledger/fabric/peer/chaincode.InitCmdFactory(0x1482fcf, 0x6, 0x101, 0x1a, 0x13b1dc0, 0xc420181f90)
    /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/common.go:369 +0xb19
github.com/hyperledger/fabric/peer/chaincode.chaincodeInvoke(0xc4200d9680, 0x0, 0x0, 0x0)
    /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/invoke.go:53 +0xff
github.com/hyperledger/fabric/peer/chaincode.invokeCmd.func1(0xc4200d9680, 0xc4202be600, 0x0, 0x17, 0x0, 0x0)
    /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/invoke.go:26 +0x34
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0xc4200d9680, 0xc4202be480, 0x17, 0x18, 0xc4200d9680, 0xc4202be480)
    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:698 +0x46d
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1c90320, 0x1d78c30, 0xf, 0x1)
    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(0x1c90320, 0x1, 0xffffffffffffffff)
    /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:736 +0x2b
main.main()
    /opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:97 +0x5bf

我们正在使用v1.3的结构。我们该如何解决呢?

语素

如果CORE_PEER_TLS_CLIENTCERT_FILECORE_PEER_TLS_CLIENTKEY_FILE不存在,则会发生上述错误您不会收到错误消息,指出文件不存在。相反,您会收到上述错误。

另外,CORE_PEER_ADDRESS并且CORE_PEER_TLS_ROOTCERT_FILE需要进行设置。如果您未设置环境变量,Fabric将使用core.yaml这些变量中的设置

func NewPeerClientForAddress(address, tlsRootCertFile string) (*PeerClient, error) {
    if address == "" {
        return nil, errors.New("peer address must be set")
    }

    _, override, clientConfig, err := configFromEnv("peer")
    if clientConfig.SecOpts.UseTLS {
        if tlsRootCertFile == "" {
            return nil, errors.New("tls root cert file must be set")
        }
        caPEM, res := ioutil.ReadFile(tlsRootCertFile)
        if res != nil {
            err = errors.WithMessage(res, fmt.Sprintf("unable to load TLS root cert file from %s", tlsRootCertFile))
            return nil, err
        }
        clientConfig.SecOpts.ServerRootCAs = [][]byte{caPEM}
    }
    return newPeerClientForClientConfig(address, override, clientConfig)
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章