hyperledger-fabrichyperledgerhyperledger-composer

Hyperledger Fabric - Lost my network card, how to export it again?


I have setup a dev hyperledger fabric blockchain successfully and added an user/participant to the network. Execute the operations again and the blockchain all worked fine with using the card that was generated initially. But now, I have lost this card, can I export/download it again? I tried using identity "revoke" api, but it is failing with this error -

Error: Error trying invoke business network. Error: No valid responses from any peers. Response from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: attempt to get property state on an InvalidRelationship is not allowed. InvalidRelationship created due to Object with ID 'partcipant_1' in collection with ID 'Asset:org.hyperledger.composer.system.Identity' does not exist


Solution

  • I am not exactly sure what you mean when you say you "lost" the card. The process goes like this:

    1. you have an admin user with full rights to the network and an admin card to connect with, using this admin
    2. you request a new identity, this gives you the required certificates, both public and private
    3. you create a network card for this new identity using the certificates. This results in a physical .card file on disk
    4. you import the physical file and you have a properly registered card and can now interact with the ledger, using this new identity.

    if anything happens to the card itself, ie you deleted the registered card and got rid of the file as well, then you need to go through the process and recreate the card from scratch.

    your commands could look like this:

    composer identity request -c PeerAdmin@hlfv1 -u admin -s adminpw -d alice
    

    this requests everything for a new user called alice, using the peer admin card which is created against the original network admin

    composer card create -p your_connection.json -u alice -n your-network -c alice/admin-pub.pem -k alice/admin-priv.pem
    

    this creates the card file

    composer card import -f alice@your-network.card
    

    this imports the card

    composer network ping -c alice@your-network
    

    check everything works

    so, if you no longer have a registered card, you should still have the .card file and if you have that you can simply import it again.

    if you don't have the .card file either, you should still have the certificates for "alice" and should be able to create the .card file

    if you don't have the certs either then request them again ( I've never tried this particular scenario so we need to see what happens in that case )