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

cfssl to generating certificates #1001

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test-network/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ function checkPrereqs() {
fi
done

## check for cfssl binaries
if [ "$CRYPTO" == "cfssl" ]; then

cfssl version > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
errorln "cfssl binary not found.."
errorln
errorln "Follow the instructions to install the cfssl and cfssljson binaries:"
errorln "https://github.com/cloudflare/cfssl#installation"
exit 1
fi
fi

## Check for fabric-ca
if [ "$CRYPTO" == "Certificate Authorities" ]; then

Expand Down Expand Up @@ -182,6 +195,26 @@ function createOrgs() {

fi

# Create crypto material using cfssl
if [ "$CRYPTO" == "cfssl" ]; then

. organizations/cfssl/registerEnroll.sh
#function_name cert-type CN org
peer_cert peer peer0.org1.example.com org1
peer_cert admin [email protected] org1

infoln "Creating Org2 Identities"
#function_name cert-type CN org
peer_cert peer peer0.org2.example.com org2
peer_cert admin [email protected] org2

infoln "Creating Orderer Org Identities"
#function_name cert-type CN
orderer_cert orderer orderer.example.com
orderer_cert admin [email protected]

fi

# Create crypto material using Fabric CA
if [ "$CRYPTO" == "Certificate Authorities" ]; then
infoln "Generating certificates using Fabric CA"
Expand Down Expand Up @@ -452,6 +485,9 @@ while [[ $# -ge 1 ]] ; do
-ca )
CRYPTO="Certificate Authorities"
;;
-cfssl )
CRYPTO="cfssl"
;;
-r )
MAX_RETRY="$2"
shift
Expand Down
22 changes: 22 additions & 0 deletions test-network/organizations/cfssl/admin-csr-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"CN": "{USER}",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "admin"
}
],
"hosts": [
"{USER}",
"localhost",
"127.0.0.1",
"0.0.0.0"
]
Comment on lines +16 to +21
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized that you generate a single certificate and use it for both the MSP enrollment cert (e.g. role 'admin' above) and the TLS cert (hosts defined for tls cert SAN here).
While this will technically work, it is not a good practice, production environments should have separate certs for msp and tls. And while the samples here are not expected to be used in production environments, the samples are intended to be an educational resource and there is a lot of confusion about proper use of certificates.
I'd suggest to split the certificates to make their usage more clear - have one msp enrollment cert with the OU role defined, and a seprate tls cert with the hosts SAN entries.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certs will be different as we are generating MSP and TLS certs with different profiles, we have two profiles (sign and tls) that governs if the certificates are for signing or TLS purpose.

}
21 changes: 21 additions & 0 deletions test-network/organizations/cfssl/ca-orderer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"CN": "cfssl-orderer-ca",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "client"
}
],
"hosts": [
"localhost",
"127.0.0.1",
"0.0.0.0"
]
}
21 changes: 21 additions & 0 deletions test-network/organizations/cfssl/ca-peer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"CN": "cfssl-peer-ca",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "Fabric"
}
],
"hosts": [
"localhost",
"127.0.0.1",
"0.0.0.0"
]
}
27 changes: 27 additions & 0 deletions test-network/organizations/cfssl/cert-signing-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"signing": {
"default": {
"expiry": "175200h"
},
"profiles": {
"sign": {
"usages": [
"signing",
"key encipherment",
"cert sign",
"digital signature"
],
"expiry": "175200h"
},
"tls": {
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
],
"expiry": "175200h"
}
}
}
}
22 changes: 22 additions & 0 deletions test-network/organizations/cfssl/client-csr-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"CN": "{USER}",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "client"
}
],
"hosts": [
"{USER}",
"localhost",
"127.0.0.1",
"0.0.0.0"
]
}
22 changes: 22 additions & 0 deletions test-network/organizations/cfssl/orderer-csr-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"CN": "{USER}",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "orderer"
}
],
"hosts": [
"{USER}",
"localhost",
"127.0.0.1",
"0.0.0.0"
]
}
22 changes: 22 additions & 0 deletions test-network/organizations/cfssl/peer-csr-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"CN": "{USER}",
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "IN",
"ST": "Delhi",
"L": "Aero city",
"O": "cfssl",
"OU": "peer"
}
],
"hosts": [
"{USER}",
"localhost",
"127.0.0.1",
"0.0.0.0"
]
}
Loading