Search code examples
hyperledgerhyperledger-composer

Unable to issue identity in Hyperledger Composer


I am trying to issue an identity to a participant that already exists in the network.

 return this.bizNetworkConnection.connect(this.cardname)
     .then((result) => {
         let email = 'user@gmail.com',
             username = email.split('@')[0];

         this.businessNetworkDefinition = result;

         return this.bizNetworkConnection.issueIdentity('org.test.Person#user@gmail.com', username);
     })
    .then((result) => {
        console.log(`userID = ${result.userID}`);
        console.log(`userSecret = ${result.userSecret}`);

     })

I expect that I will see the userID and the userSecret logged on the console but I am getting errors as described below.

Following the developer tutorial on their documents:

  1. If I use the card name for PeerAdmin@hlfv1 on the connect function above, I get the error. "Error trying to ping. Error: Error trying to query business network. Error: Missing \"chaincodeId\" parameter in the proposal request"
  2. If I use the card name for admin@tutorial-network on the connect function above, I get the error "fabric-ca request register failed with errors [[{\"code\":400,\"message\":\"Authorization failure\"}]]"

For option 1, I know the network name is missing in the given card, whie option 2 means that the admin has no rights to issue an identity. However, I cannot seem to find any documentation directing me on how to use either to achieve my objective. Any help is highly welcome.

While I have listed the javascript code I am using to achieve the same, I would not mind if anyone can explain what I am missing using the composer cli.


Solution

  • see https://hyperledger.github.io/composer/latest/managing/identity-issue.html

    you would definitely use the admin@tutorial-network card, as PeerAdmin does not have authority to issue identities (admin does).

    Did you already do: 1) a composer card import -f networkadmin.card (per the tutorial) ? 2) a composer network ping -c admin@tutorial-network to use the card (now in the card store) and thereby populate the admin's credentials (certificate/private key).

    Only at that point would admin be recognised as the identity to issue further identities. Is it possible you spun up a new dockerized CA server at some stage since you did the import etc ?

    What happens if you issue a test identity through the command line (using admin@tutorial-network? Does it fail)