Skip to content

Commit 650fb6b

Browse files
yacovmmastersingh24
authored andcommitted
[FAB-5845] Separate trusted roots upon join channel
The current code assumes that the application orgs and the orderer orgs are separate, but a peer and an orderer may be in the same org and then this code might not (for example) populate the orderer TLS root CA certs. The implication, is that a peer might not be able to connect to an orderer. Change-Id: Ia19a45b42837d223282ce15402ebd5b4a3cb121b Signed-off-by: yacovm <[email protected]> (cherry picked from commit cf82b4e) Signed-off-by: Gari Singh <[email protected]>
1 parent 1c56557 commit 650fb6b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

core/peer/peer.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,22 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
382382
appRootCAs := [][]byte{}
383383
ordererRootCAs := [][]byte{}
384384
appOrgMSPs := make(map[string]struct{})
385-
ac, ok := cm.ApplicationConfig()
386-
if ok {
385+
ordOrgMSPs := make(map[string]struct{})
386+
387+
if ac, ok := cm.ApplicationConfig(); ok {
387388
//loop through app orgs and build map of MSPIDs
388389
for _, appOrg := range ac.Organizations() {
389390
appOrgMSPs[appOrg.MSPID()] = struct{}{}
390391
}
391392
}
392393

394+
if ac, ok := cm.OrdererConfig(); ok {
395+
//loop through orderer orgs and build map of MSPIDs
396+
for _, ordOrg := range ac.Organizations() {
397+
ordOrgMSPs[ordOrg.MSPID()] = struct{}{}
398+
}
399+
}
400+
393401
cid := cm.ChainID()
394402
peerLogger.Debugf("updating root CAs for channel [%s]", cid)
395403
msps, err := cm.MSPManager().GetMSPs()
@@ -405,7 +413,9 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
405413
if _, ok := appOrgMSPs[k]; ok {
406414
peerLogger.Debugf("adding app root CAs for MSP [%s]", k)
407415
appRootCAs = append(appRootCAs, root)
408-
} else {
416+
}
417+
// check to see of this is an orderer org MSP
418+
if _, ok := ordOrgMSPs[k]; ok {
409419
peerLogger.Debugf("adding orderer root CAs for MSP [%s]", k)
410420
ordererRootCAs = append(ordererRootCAs, root)
411421
}
@@ -415,7 +425,9 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
415425
if _, ok := appOrgMSPs[k]; ok {
416426
peerLogger.Debugf("adding app root CAs for MSP [%s]", k)
417427
appRootCAs = append(appRootCAs, intermediate)
418-
} else {
428+
}
429+
// check to see of this is an orderer org MSP
430+
if _, ok := ordOrgMSPs[k]; ok {
419431
peerLogger.Debugf("adding orderer root CAs for MSP [%s]", k)
420432
ordererRootCAs = append(ordererRootCAs, intermediate)
421433
}

0 commit comments

Comments
 (0)