Skip to content

Commit 1c6ef12

Browse files
author
Anil Ambati
committed
[FAB-7291] Set default value for Chainfile attribute
In a fabric CA cluster that has two servers, if the cluster members are started in parallel, there is a chance one server will initialize before the other. When this happens, first server will enroll and get a CA cert, private key and a CA chain and store them on the shared file system. The second server will skip the enrollment since enrollment was done by the first server, so getCACert method is not invoked. Since the cfg.CA.Chainfile variable is set in the getCACert method, its value will remain as an empty string. This causes an error when getcacerts request is sent to the second server. Fix is to set the cfg.CA.Chainfile to default value "ca-chain.pem" if a value is not specified by the user. With this change, cluster fvt test passes. This problem was introduced by the change set: https://gerrit.hyperledger.org/r/c/15373/. The problem was uncovered by cluster_test.sh fvt script. This script did not exist when first patch set for 15373 was submitted. Since there was no conflict between these two changes, the Gerrit did not complain. Change-Id: I1eb8db05fc9f79b7cbb989188c4f65bb8655ded1 Signed-off-by: Anil Ambati <aambati@us.ibm.com>
1 parent e47038f commit 1c6ef12

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/ca.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,6 @@ func (ca *CA) getCACert() (cert []byte, err error) {
316316
cert = ecert.Cert()
317317
// Store the chain file as the concatenation of the parent's chain plus the cert.
318318
chainPath := ca.Config.CA.Chainfile
319-
if chainPath == "" {
320-
chainPath, err = util.MakeFileAbs("ca-chain.pem", ca.HomeDir)
321-
if err != nil {
322-
return nil, errors.WithMessage(err, "Failed to create intermediate chain file path")
323-
}
324-
ca.Config.CA.Chainfile = chainPath
325-
}
326319
chain, err := ca.concatChain(resp.ServerInfo.CAChain, cert)
327320
if err != nil {
328321
return nil, err
@@ -441,6 +434,9 @@ func (ca *CA) initConfig() (err error) {
441434
if cfg.CA.Keyfile == "" {
442435
cfg.CA.Keyfile = "ca-key.pem"
443436
}
437+
if cfg.CA.Chainfile == "" {
438+
cfg.CA.Chainfile = "ca-chain.pem"
439+
}
444440
if cfg.CSR.CA == nil {
445441
cfg.CSR.CA = &cfcsr.CAConfig{}
446442
}

lib/caconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type CAInfo struct {
109109
Name string `opt:"n" help:"Certificate Authority name"`
110110
Keyfile string `help:"PEM-encoded CA key file"`
111111
Certfile string `def:"ca-cert.pem" help:"PEM-encoded CA certificate file"`
112-
Chainfile string `help:"PEM-encoded CA chain file"`
112+
Chainfile string `def:"ca-chain.pem" help:"PEM-encoded CA chain file"`
113113
}
114114

115115
// CAConfigDB is the database part of the server's config

scripts/fvt/cluster_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ EOF
270270
if test "$SERVER" = "$INTERMEDIATE_PROXY_PORT"; then
271271
dbname=$INTDBNAME
272272
userdir=$INTUSERDIR
273-
stype=root
273+
stype=intermediate
274274
backend=intserver
275275
else
276276
dbname=$DBNAME
277277
userdir=$ROOTUSERDIR
278-
stype=intermediate
278+
stype=root
279279
backend=server
280280
fi
281281

0 commit comments

Comments
 (0)