0

我编写了配置文件 connect.yaml 并尝试将链码与 go 程序连接起来。但是出现了以下错误:

2021/08/29 17:10:04 无法连接到网关:无法应用配置选项:无法初始化配置:无法加载身份配置:无法从配置后端初始化身份配置:无法从后端创建身份配置:无法将“certificateAuthorities”配置项解析为 identityConfigEntity.CertificateAuthorities 类型:3 错误解码:

  • '[ca.agridepart.amops.com].Registrar' 期待一张地图,得到了 'slice'
  • '[ca.agrimacowner.amops.com].Registrar' 期待一张地图,得到了 'slice'
  • '[ca.financedepart.amops.com].Registrar' 期待一张地图,得到了 'slice'

然后我尝试在connect.yaml文件的certificateAuthorities部分删除以下内容

registrar:
     -enrollId: admin
       enrollSecret: adminpw

但是出现以下错误: 2021/08/29 17:38:57 Failed to get network: Failed to create new channel client: event service creation failed: could not get chConfig cache reference: QueryBlockConfig failed: QueryBlockConfig failed: target(s)必需的

那么第二个错误是否与第一个错误有关以及导致它的原因。我应该怎么办?

我的 connect.yaml 文件内容如下:

---
name: amops
version: 1.0.0
client:
  organization: Agridepart
  connection:
    timeout:
      peer:
        endorser: '300'
      orderer: '300'
channels:
  amops:
    orderers:
    - agridepartorderer.amops.com
    - agrimacownerorderer.amops.com
    - financedepartorderer.amops.com
    peers:
      peer0.agridepart.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
      peer0.agrimacowner.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
      peer0.financedepart.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
  Agridepart:
    mspid: AgridepartMSP
    peers:
    - peer0.agridepart.amops.com
    certificateAuthorities:
    - ca.agridepart.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/users/Admin@agridepart.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/users/Admin@agridepart.amops.com/msp/signcerts/Admin@agridepart.example.com-cert.pem"
  Agrimacowner:
    mspid: AgrimacownerMSP
    peers:
    - peer0.agrimacowner.amops.com
    certificateAuthorities:
    - ca.agrimacowner.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/users/Admin@agrimacowner.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/users/Admin@agrimacowner.amops.com/msp/signcerts/Admin@agrimacowner.amops.com-cert.pem"
  Financedepart:
    mspid: FinancedepartMSP
    peers:
    - peer0.financedepart.amops.com
    certificateAuthorities:
    - ca.financedepart.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/users/Admin@financedepart.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/users/Admin@financedepart.amops.com/msp/signcerts/Admin@financedepart.amops.com-cert.pem"
orderers:
  agridepartorderer.amops.com:
    url: grpcs://192.168.32.165:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: agridepartorderer.amops.com
      hostnameOverride: agridepartorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/agridepartorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
  agrimacownerorderer.amops.com:
    url: grpcs://192.168.32.170:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: agrimacownerorderer.amops.com
      hostnameOverride: agrimacownerorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/agrimacownerorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
  financedepartorderer.amops.com:
    url: grpcs://192.168.32.171:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: financedepartorderer.amops.com
      hostnameOverride: agrimacownerorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/financedepartorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
peers:
  peer0.agridepart.amops.com:
    url: grpcs://192.168.32.165:7051
    grpcOptions:
      ssl-target-name-override: peer0.agridepart.amops.com
      hostnameOverride: peer0.agridepart.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/peers/peer0.agridepart.amops.com/tls/ca.crt"
  peer0.agrimacowner.amops.com:
    url: grpcs://192.168.32.170:7051
    grpcOptions:
      ssl-target-name-override: peer0.agrimacowner.amops.com
      hostnameOverride: peer0.agrimacowner.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/peers/peer0.agrimacowner.amops.com/tls/ca.crt"
  peer0.financedepart.amops.com:
    url: grpcs://192.168.32.171:7051
    grpcOptions:
      ssl-target-name-override: peer0.financedepart.amops.com
      hostnameOverride: peer0.financedepart.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/peers/peer0.financedepart.amops.com/tls/ca.crt"
certificateAuthorities:
  ca.agridepart.amops.com:
    url: https://192.168.32.165:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/ca/ca.agridepart.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw
  ca.agrimacowner.amops.com:
    url: https://192.168.32.170:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/ca/ca.agrimacowner.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw
  ca.financedepart.amops.com:
    url: https://192.168.32.171:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/ca/ca.financedepart.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw
4

0 回答 0