"CA" 在 Hyperledger Fabric 中创建的管理员和用户与 "cryptogen" 创建的管理员和用户

Admin & users created by "CA" vs Admin & users created by "cryptogen" in Hyperledger Fabric

我是 Hyperledger Fabric 的新手。我遇到了织物的一个非常混乱的部分。

那么到底发生了什么? 流量是多少? 这些管理员一次又一次创建有什么区别?

我明白了,CA 服务器容器安装了一个卷,指向 crypto-config 文件夹,其中已经有 cryptogen 生成的证书和密钥。

类似的现有答案不是我要找的。我想要一个深入的洞察力。 谢谢

我不知道 fabcar 是做什么的,但也许我可以向您澄清一些 Hyperledger Fabric 概念。

cryptogen 是一个开发工具,用于生成您最初开发 Fabric 网络所需的所有(MSP 和 TLS 相关的)加密内容。

对于更严肃的部署,您可以改用 Fabric-CA。 Fabric-CA 是一个证书颁发机构,维护为您的组织注册的身份的数据库,并允许您的注册参与者注册他们的证书。您还可以更新身份、吊销身份和证书等

然后你必须区分 CA 管理员和组织管理员。您首先注册CA 管理员,否则您无法注册身份。组织管理员只是组织的具有管理员角色的身份。

通常情况下,注册的 CA 管理员会生成所有身份。之后,稍后,在其他地方,组织管理员(或任何其他身份)通过指定注册时声明的用户和密码来注册其证书。

好的,所以在连续 1 周的挖掘之后,我找到了问题的确切答案。 首先,我想确定织物样品应用程序的确切流程和结构。

  • Fabcar 和 Commercial Paper 是两个不同的应用程序 由面料作为面料样品的一部分提供。
  • Fabcar使用first-network,Commercial Paper使用basic-network
  • Fabcar 的链代码在链代码文件夹中,而 Commercial Paper 的链代码在两个组织的合同文件夹中。
  • 管理员使用 peer chaincode installpeer chaincode instantiate 安装链代码后(不要将此管理员与 CA 管理员混淆,​​这只是管理通道的开发人员),合约对所有人可用各个频道的组成部分。
  • 现在我们需要有特定的应用程序来调用通道已知的合约。 Fabcar和Commercial Paper在各自的应用文件夹中都有不同的应用。
  • 应用程序可以通过网关与我们的通道交互或说底层结构层。

The Hyperledger Fabric SDK provides a gateway abstraction so that applications can focus on application logic while delegating network interaction to the gateway. Gateways and wallets make it straightforward to write Hyperledger Fabric applications. Find here in the docs

  • 我们的应用程序需要一些身份才能使用底层结构层。在允许访问网络之前,网关会检查此身份的真实性。
  • Fabric 使用密钥和签名证书的概念来执行此身份验证。

在这里进入一个不同的概念,fabric 提供了两种认证架构(架构可能不是正确的词),

  • cryptogen - 通常用于开发或测试目的以生成密钥和证书
  • Certificate Authority - 不是新概念,fabric 使用它来生成证书。任何 CA 服务器都需要 admin 才能生成证书。 在启动服务器本身时,这个 bootstrap 身份是使用 fabric-ca-server start 和带有 username:password 参数的 -b 选项创建的。

回到 fabric,在启动任何网络(基本网络或第一网络)之前,fabric 要求我们生成 cryto-config。

  • 商业票据使用 cryptogen 先前生成的 crypto-config 生成的证书和密钥来生成应用程序的身份。
  • Fabcar 使用 CA 生成证书和密钥。当我们在 Fabcar 中启动我们的 CA 服务器容器时,管理员已经注册。我们只是在注册时给了他证书和钥匙。新用户需要注册和注册(使用 CA 管理员身份完成)。

The private and public key are first generated locally and the public key is then sent to the CA which returns an encoded certificate for use by the application. These three credentials are then stored in the wallet, allowing us to act as an administrator for the CA. Find here in the docs

所以 Fabcar 使用 CA 以及 Commercial-Paper 使用 cryptogen 并不是结构设计造成的,这只是选择而已。

我将结束我的回答,引用织物文档中的确切声明。

  • When we created the network, an admin user literally called admin was created as the registrar for the certificate authority (CA). Our first step is to generate the private key, public key, and X.509 certificate for admin using the enroll.js program. This process uses a Certificate Signing Request (CSR) — the private and public key are first generated locally and the public key is then sent to the CA which returns an encoded certificate for use by the application. These three credentials are then stored in the wallet, allowing us to act as an administrator for the CA. We will subsequently register and enroll a new application user which will be used by our application to interact with the blockchain. Find here in the docs

  • addToWallet.js is the program that Isabella is going to use to load her identity into her wallet, and issue.js will use this identity to create commercial paper 00001 on behalf of MagnetoCorp by invoking papercontract. Find here in the docs

欢迎专家指正。这些是我从代码观察中得出的推论。

一些理论:cryptogen 只是一个用 golang 编写的工具,它的作用是创建一个自签名根 ca 和一些签名证书(组织管理员、用户、实体)

现在当你启动 CA 时,如果你想使用由 cryptogen 生成的相同证书和密钥,那么你将使用下面的命令

fabric-ca-server start -b myorgadmin:myorgpw -d

否则,如果您不想使用 cryptogen 生成的证书,那么您可以使用以下命令,您应该忘记 cryptogen 生成的证书,因为它们不再使用,您必须自己生成

fabric-ca-server init -b myorgadmin:myorgpw

差异是 init 命令

Bootstrap CA server credentials are in order to authenticate for future purposes

Ex: If you want to register a new user then you need to authenticate with credentials

以后可以使用cryptogen生成的用户证书,也可以通过认证CA服务器注册不同的用户