Skip to content

Commit

Permalink
[FAB-5845] Separate trusted roots upon join channel
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
yacovm authored and mastersingh24 committed Aug 28, 2017
1 parent 1c56557 commit 650fb6b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,22 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
appRootCAs := [][]byte{}
ordererRootCAs := [][]byte{}
appOrgMSPs := make(map[string]struct{})
ac, ok := cm.ApplicationConfig()
if ok {
ordOrgMSPs := make(map[string]struct{})

if ac, ok := cm.ApplicationConfig(); ok {
//loop through app orgs and build map of MSPIDs
for _, appOrg := range ac.Organizations() {
appOrgMSPs[appOrg.MSPID()] = struct{}{}
}
}

if ac, ok := cm.OrdererConfig(); ok {
//loop through orderer orgs and build map of MSPIDs
for _, ordOrg := range ac.Organizations() {
ordOrgMSPs[ordOrg.MSPID()] = struct{}{}
}
}

cid := cm.ChainID()
peerLogger.Debugf("updating root CAs for channel [%s]", cid)
msps, err := cm.MSPManager().GetMSPs()
Expand All @@ -405,7 +413,9 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
if _, ok := appOrgMSPs[k]; ok {
peerLogger.Debugf("adding app root CAs for MSP [%s]", k)
appRootCAs = append(appRootCAs, root)
} else {
}
// check to see of this is an orderer org MSP
if _, ok := ordOrgMSPs[k]; ok {
peerLogger.Debugf("adding orderer root CAs for MSP [%s]", k)
ordererRootCAs = append(ordererRootCAs, root)
}
Expand All @@ -415,7 +425,9 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
if _, ok := appOrgMSPs[k]; ok {
peerLogger.Debugf("adding app root CAs for MSP [%s]", k)
appRootCAs = append(appRootCAs, intermediate)
} else {
}
// check to see of this is an orderer org MSP
if _, ok := ordOrgMSPs[k]; ok {
peerLogger.Debugf("adding orderer root CAs for MSP [%s]", k)
ordererRootCAs = append(ordererRootCAs, intermediate)
}
Expand Down

0 comments on commit 650fb6b

Please sign in to comment.