Create "PeerAdmin@hlfv1" Card Manually

Q

How to create the "PeerAdmin@hlfv1" card manually?

✍: FYIcenter.com

A

If you don't want to use the "createPeerAdminCard.sh" script to create the "PeerAdmin@hlfv1" card automatically, you can follow this tutorial to create it manually.

1. Create connection profile "connection.json":

$ mkdir ~/card 
$ cd ~/card 
$ vi connection.json

{
    "name": "hlfv1",
    "x-type": "hlfv1",
    "x-commitTimeout": 300,
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {}
    },
    "channels": {
        "composerchannel": {
            "orderers": ["orderer.example.com"],
            "peers": {"peer0.org1.example.com": {}}
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": ["peer0.org1.example.com"],
            "certificateAuthorities": ["ca.org1.example.com"]
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc:\/\/localhost:7050"
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc:\/\/localhost:7051"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http:\/\/localhost:7054",
            "caName": "ca.org1.example.com"
        }
    }
}

2. Copy the certificate and the private of admin user, "Admin@org1.example.com" included in the installation package:

$ cd ~/fabric-dev-servers/fabric-scripts/hlfv12/composer/crypto-config \
   /peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 
   
$ cp admincerts/Admin@org1.example.com-cert.pem ~/card/cert.pem
   
$ cp keystore/114a...4457_sk ~/card/key.pem

3. Build the card file, PeerAdmin.card:

$ cd ~/card 

$ composer card create -p connection.json -u PeerAdmin@hlfv1 \
   -c cert.pem -k key.pem -r PeerAdmin -r ChannelAdmin -f PeerAdmin.card

Successfully created business network card file to
        Output file: PeerAdmin.card

Command succeeded

$ ls -l 
-rw-rw-r-- 1 fyicenter 1977 Apr  1 02:00 PeerAdmin.card
-rw-r--r-- 1 fyicenter  790 Apr  1 01:32 cert.pem
-rw-rw-r-- 1 fyicenter  419 Apr  1 01:15 connection.json
-rwxr-xr-x 1 fyicenter  241 Apr  1 01:33 key.pem

4. Import the card file to wallet, ~/.composer/cards:

$ composer card import -f PeerAdmin@fabric-network.card

Successfully imported business network card
        Card file: PeerAdmin.card
        Card name: PeerAdmin@hlfv1@hlfv1

Command succeeded

5. Check access cards in wallet:

$ composer card list
The following Business Network Cards are available:

Connection Profile: hlfv1
┌───────────────────────┬─────────────────┬──────────────────┐
│ Card Name             │ UserId          │ Business Network │
├───────────────────────┼─────────────────┼──────────────────┤
│ PeerAdmin@hlfv1       │ PeerAdmin       │                  │
├───────────────────────┼─────────────────┼──────────────────┤
│ PeerAdmin@hlfv1@hlfv1 │ PeerAdmin@hlfv1 │                  │
└───────────────────────┴─────────────────┴──────────────────┘

There are 2 cards now in the Composer wallet:

  • "PeerAdmin@hlfv1" created by the "createPeerAdminCard.sh" script.
  • "PeerAdmin@hlfv1@hlfv1" created by manually by the "composer card create" command.
  • Both cards represent the same admin user "Admin@org1.example.com" with the same certificate signed by the root CA of "ca.org1.example.com".

 

"composer card" Commands

"PeerAdmin@hlfv1" - Peer Admin Access Card

Explorer Hyplerledger Composer Environment

⇑⇑ Hyperledger Composer Tutorials

2020-07-14, 216👍, 0💬