Reputation: 41
I am a newbie to Hyperledger Fabric. I came across a very confusing part of fabric.
Cryptogen is used to generate certs and keys for users and admin in an organisation.
Talking specifically about fabcar, A very similar thing is the done by:
So what exactly is happening? What is the flow? What is the difference between these admins created again and again?
I see, CA server container has a volume mounted, pointing back to the crypto-config folder which already have certs and keys generated by cryptogen.
Similar existing answers is not what I am looking for. I want an in-depth insight. Thanks.
Upvotes: 1
Views: 901
Reputation: 4133
Some Theory: cryptogen is just a tool written in golang and what it does is it will create a self-signed root ca and some signed certificates(org admin, users, entities)
Now when you start CA, if you want to use the same cert and key generated by cryptogen then you will use below command
fabric-ca-server start -b myorgadmin:myorgpw -d
ELSE if you do not want to use cryptogen generated certificates then you can use below command and you should forget about cryptogen generated certificates because they no longer use and you have to generate by yourself
fabric-ca-server init -b myorgadmin:myorgpw
DIFFERENCE is init
command
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
In future, you can use cryptogen generated user certificates or you can register different users by authenticating CA server
Upvotes: 1
Reputation: 41
Okay, so after digging around for continuous 1 week I found exact answer to the question. First, I would like to lay down exact flow and structure of fabric samples applications.
peer chaincode install
and peer chaincode instantiate
the contract becomes available to all the components of the respective channels.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
Diving into a different concept here, fabric provides two kind of certification architectures (architecture might not be the correct word),
admin
to allow generating certificates.
While bringing up the server itself, this bootstrap identity is created using fabric-ca-server start
with a -b
option with username:password
parameter. Coming back to fabric, before starting any network (basic-network or first-network) fabric asks us to generate cryto-config.
crypto-config
by cryptogen to generate identities for the application.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
So it's not by design of fabric why Fabcar used CA
and why Commercial-Paper used cryptogen
, it's simply by choice.
I'll end my answer, quoting exact statement from the fabric documentation.
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
Any corrections from experts are very welcome. These are my deductions from code observation.
Upvotes: 2
Reputation: 2200
I don't know what fabcar does, but maybe I can clarify some Hyperledger Fabric concepts to you.
cryptogen
is a development tool using for generating all the (MSP and TLS related) cryptographic stuff you need initially for your development Fabric network.
For more serious deployments, you use Fabric-CA instead. Fabric-CA is a Certification Authority that maintains a database of the identities registered for your organization and allow your registered actors to enroll their certificates. You can also update identities, revoke identities and certificates, etc.
And then you have to distinguish a CA administrator from a organization administrator. You first enroll the CA administrator, otherwise you cannot register identities. And a organization admin is simply an identity with role admin for the organization.
Normally, the enrolled CA administrator generates all the identities. After that, later, in other place, the organization administrator (or any other identity) enrolls its certificate by specifying the user and password declared during registration.
Upvotes: 1