实验第二节——生成必要的身份证书文件

一、创建工作目录

  1. 使用命令:mkdir -p /home/test_fabric/crypto-config创建目录,之后将生成的文件放入此目录中使用

二、编辑crypto-config.yaml

2.1crypto-config.yaml存放位置

  1. 使用命令:touch /home/test_fabric/crypto-config.yaml,创建crypto-config.yaml

2.2 crypto-config.yaml组织结构

  1. 定义4个order节点——orderer0,orderer1,orderer2,orderer3
  2. 定义三个组织——Org1,Org2,Org3
  3. 每个组织定义一个用户

2.3编写crypto-config.yaml

  1. 将下面文件内容复制进crypto-config.yaml中
OrdererOrgs:
  - Name: Orderer
    Domain: example.com
    EnableNodeOUs: true
    CA:
        Country: US
        Province: California
        Locality: San Francisco
    Specs:
      - Hostname: orderer0
      - Hostname: orderer1
      - Hostname: orderer2
      - Hostname: orderer3
PeerOrgs:
  - Name: Org1
    Domain: org1.example.com
    EnableNodeOUs: true
    CA:
        Country: US
        Province: California
        Locality: San Francisco
    Template:
      Count: 2
    Users:
      Count: 1

  - Name: Org2
    Domain: org2.example.com
    EnableNodeOUs: true
    CA:
        Country: US
        Province: California
        Locality: San Francisco
    Template:
      Count: 2
    Users:
      Count: 1

  - Name: Org3
    Domain: org3.example.com
    EnableNodeOUs: true
    CA:
        Country: US
        Province: California
        Locality: San Francisco
    Template:
      Count: 2
    Users:
      Count: 1

三、利用docker执行cryptogen generate命令生成必要的证书相关文件

  1. 生成docker,使用-it参数以交互形式进入容器,使用参数–rm指定推出容器后自动删除容器,容器生成命令
docker run \
  --rm -it \
  --name generator \
  -e "CONFIGTX_LOGGING_LEVEL=DEBUG" \
  -v /home/test_fabric/crypto-config:/tmp/crypto-config \
  -v /home/test_fabric/crypto-config.yaml:/tmp/crypto-config.yaml \
  yeasy/hyperledger-fabric:2.3.3 /bin/bash
  1. 进入/tmp目录执行命令:cryptogen generate --config=crypto-config.yaml --output crypto-config
  2. 退出容器,在本地执行命令:tree /home/test_fabric/crypto-config查看生成的证书相关文件
  3. 这里容器使用的cryptogen版本信息
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37589805/article/details/121869263