Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CA capability to test-network-nano-bash #1209

Merged
merged 1 commit into from
May 29, 2024

Conversation

celder628
Copy link

This change adds:

  • shell scripts to start CAs for each org
  • optional flag (-c) to network.sh to start CAs
  • generate crypto material in the same format as cryptogen using the CAs
  • describe how to start the CAs using terminals

@celder628 celder628 requested a review from a team as a code owner May 23, 2024 15:12
@celder628 celder628 force-pushed the AddCAsToTestNetworkNanoBash branch 3 times, most recently from ae83c86 to b257d68 Compare May 24, 2024 19:36

- cd to the `test-network-nano-bash` directory in each terminal window
- Instead of running the `./generate_artifacts.sh` described above, in the three CA terminals, run `./ordererca.sh`, `./org1ca.sh`, `./org2ca.sh` respectively.
- In the first orderer terminal, run `./generate_artifacts.sh "" true` to generate crypto material using the CAs and application channel genesis block and configuration transactions (calls configtxgen). The artifacts will be created in the `crypto-config` and `channel-artifacts` directories. If you are running BFT consensus then run `./generate_artifacts.sh BFT true`. All artifacts generated with the CA will conform to the same directory structure as cryptogen.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing generate_artifacts to accept flags such as -bft and -ca? generate_artifacts.sh "" true isn't very expressive.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been corrected.

# registerAndEnroll()
#
# This is a convenience method for creating enrollments and TLS certificates
# Primary purpose it to create enrollment certificates for admin identities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Primary purpose it to create enrollment certificates for admin identities
# Primary purpose it to create enrollment certificates for org admin identities, and

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

# Rename the cacert to mimic cryptogen
mv ${component_dir}/msp/cacerts/localhost-${port}-ca.pem ${component_dir}/msp/cacerts/ca.${orgname:+$orgname.}example.com-cert.pem

# Set the cacert name and copy the config.json for NodeOU
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CA cert doesn't use NodeOUs right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. This is not needed for the admin cert. Removing this line.

# createEnrollment()
#
# This is a convenience method for creating enrollments only
# Primary purpose it to create enrollment certificates for CAs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Primary purpose it to create enrollment certificates for CAs
# Primary purpose it to create enrollment certificates for CA admins.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Comment on lines +80 to +87
######################################################################################
# Create the certificates for Org1
######################################################################################
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity nano doesn't switch between "admin" and "client" users, it just uses the "admin" user all the time.
However, since this is an educational sample, it is probably worthwhile to create the "client" users for Org1 and Org2.

Also, it may be easier to understand if the "admin" and "client" enrollments are both done here in the respective org section, especially since the title of this section is "Create the certificates for Org1", which for educational purposes should include all the org certs - admin, client, and peers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added client enrollments to the script.

![CA Terminal setup](ca_terminal_setup.png)

- cd to the `test-network-nano-bash` directory in each terminal window
- Instead of running the `./generate_artifacts.sh` described above, in the three CA terminals, run `./ordererca.sh`, `./org1ca.sh`, `./org2ca.sh` respectively.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Instead of running the `./generate_artifacts.sh` described above, in the three CA terminals, run `./ordererca.sh`, `./org1ca.sh`, `./org2ca.sh` respectively.
- Before running `./generate_artifacts.sh`, in the three CA terminals, run `./ordererca.sh`, `./org1ca.sh`, `./org2ca.sh` respectively.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reworded this. It should make sense now:

- Before running the ./generate_artifacts.sh -cain the first orderer terminal, run./ordererca.sh, ./org1ca.sh, ./org2ca.sh in the repsective terminals.

This change adds:
- shell scripts to start CAs for each org
- optional flag (-c) to network.sh to start CAs
- generate crypto material in the same format as cryptogen using the CAs
- describe how to start the CAs using terminals

Signed-off-by: Chris Elder <celder@chriss-mbp.raleigh.ibm.com>
@celder628 celder628 force-pushed the AddCAsToTestNetworkNanoBash branch from b257d68 to 26c69cc Compare May 28, 2024 21:47
Copy link
Contributor

@denyeart denyeart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris!

@denyeart denyeart merged commit 3c63eac into hyperledger:main May 29, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants