Search code examples
hyperledger-fabrichyperledgerhyperledger-composerhyperledger-fabric-ca

Composer request identity from different host machine


I'm following this tutorial with modications made to add organisation from a different host machine. https://medium.com/@mahoney_33893/hyperledger-composer-adding-another-organization-to-an-existing-running-multi-organization-fff5c8104a82

Im trying to add a new organisation to an existing channel from a different host (say Org3). I have managed to join peer from org3 into the channel. I have CA for org3 running.

Then I created and imported a PeerAdmin card using a modified connectionprofile.

However when i ran composer identity request, I got the error message Error: failed to request identity. Error trying to enroll user and return certificates. Error: Enrollment failed with errors [[{"code":19,"message":"CA 'ca.org1.example.com' does not exist"}]]. Note that the port that runs my ca for org1 is open.

I then tried to obtain the logs from my ca in org3 only to find that (POST /api/v1/enroll 404 19 "CA 'ca.org1.example.com' does not exist). why does my ca from org3 need to communicate with ca from org1? also why does it say that my ca from org1 does not exist when it is in fact up and running? Any help is much appreciated

Currenty using hyperledger composer, hyperledger fabric v 1.2.1. Currently not using TLS.

{
"name": "hlfv1",
"x-type": "hlfv1",
"x-commitTimeout": 300,
"version": "1.0.0",
"client": {
    "organization": "Org3",
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300",
                "eventHub": "300",
                "eventReg": "300"
            },
            "orderer": "300"
        }
    }
},
"channels": {
    "composerchannel": {
        "orderers": [
            "orderer.example.com"
        ],
        "peers": {
            "peer0.org1.example.com": {},
            "peer0.org3.example.com":{}
        }
    }
},
"organizations": {
    "Org1": {
        "mspid": "Org1MSP",
        "peers": [
            "peer0.org1.example.com"
        ],
        "certificateAuthorities": [
            "ca.org1.example.com"
        ]
    },
    "Org3":{
        "mspid": "Org3MSP",
        "peers": [
            "peer0.org3.example.com"
        ],
        "certificateAuthorities": [
            "ca.org3.example.com"
        ]
    }
},
"orderers": {
    "orderer.example.com": {
        "url": "grpc://{{hostmachineurl}}:7050"
    }
},
"peers": {
    "peer0.org1.example.com": {
        "url": "grpc://{{hostmachineurl}}:7051"
    },
    "peer0.org3.example.com": {
        "url": "grpc://{{localmachineurl}}:11051"
    }
},
"certificateAuthorities": {
    "ca.org1.example.com": {
        "url": "http://{{hostmachineurl}}:7054",
        "caName": "ca.org1.example.com"
    },
    "ca.org3.example.com": {
        "url": "http://{{localmachineurl}}:9054",
        "caName": "ca.org1.example.com"
    }
}

}

my docker to create peer org3

version: '2'

volumes:
  peer0.org3.example.com:

networks:
  byfn:

services:

  peer0.org3.example.com:
    container_name: peer0.org3.example.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org3.example.com
      - CORE_PEER_ADDRESS=peer0.org3.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.example.com:7051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
        - /var/run/:/host/var/run/
        - ~/fabric-samples/first-network/org3-artifacts/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp:/etc/hyperledger/fabric/msp
        - ~/fabric-samples/first-network/org3-artifacts/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org3.example.com:/var/hyperledger/production
    ports:
      - 11051:7051
      - 11053:7053
    networks:
      - byfn

Solution

  • looking at your connection.json above - I can see why it would request from the Org1 CA (and not Org 3's CA):

    this section under "certificateAuthorities" should read "ca.org3.example.com" (see // below):

    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://{{hostmachineurl}}:7054",
            "caName": "ca.org1.example.com"
        },
        "ca.org3.example.com": {
            "url": "http://{{localmachineurl}}:9054",
            "caName": "ca.org1.example.com" // change this line
        }
    }
    

    there may well be other entries you need to check.