Hyperledger fabric Hyperledger结构:死机:运行时错误:结构/peer/common.NewPeerClientForAddress处的内存地址无效或无指针取消引用
我们正在尝试使用以下命令调用chaincode:Hyperledger fabric Hyperledger结构:死机:运行时错误:结构/peer/common.NewPeerClientForAddress处的内存地址无效或无指针取消引用,hyperledger-fabric,Hyperledger Fabric,我们正在尝试使用以下命令调用chaincode: 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_PE
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版的fabric。如何解决此问题?如果
核心对等客户端证书文件
或核心对等客户端密钥文件
不存在,则可能发生上述错误。您不会得到一个错误,说文件不存在。相反,您会得到上面的错误
此外,还需要设置和CORE\u PEER\u TLS\u ROOTCERT\u文件
。如果未设置环境变量,Fabric将使用中的设置来设置这些变量
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)
}