1
1
/*
2
- Copyright IBM Corp. 2016 All Rights Reserved.
2
+ Copyright IBM Corp. All Rights Reserved.
3
3
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
4
+ SPDX-License-Identifier: Apache-2.0
15
5
*/
16
6
17
7
package peer
@@ -22,7 +12,6 @@ import (
22
12
"net"
23
13
"sync"
24
14
25
- "github.com/golang/protobuf/proto"
26
15
"github.com/hyperledger/fabric/common/config"
27
16
"github.com/hyperledger/fabric/common/configtx"
28
17
configtxapi "github.com/hyperledger/fabric/common/configtx/api"
@@ -41,7 +30,6 @@ import (
41
30
"github.com/hyperledger/fabric/msp"
42
31
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
43
32
"github.com/hyperledger/fabric/protos/common"
44
- mspprotos "github.com/hyperledger/fabric/protos/msp"
45
33
pb "github.com/hyperledger/fabric/protos/peer"
46
34
"github.com/hyperledger/fabric/protos/utils"
47
35
"github.com/spf13/viper"
@@ -394,7 +382,6 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
394
382
appRootCAs := [][]byte {}
395
383
ordererRootCAs := [][]byte {}
396
384
appOrgMSPs := make (map [string ]struct {})
397
-
398
385
ac , ok := cm .ApplicationConfig ()
399
386
if ok {
400
387
//loop through app orgs and build map of MSPIDs
@@ -413,38 +400,24 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
413
400
for k , v := range msps {
414
401
// check to see if this is a FABRIC MSP
415
402
if v .GetType () == msp .FABRIC {
416
- for _ , root := range v .GetRootCerts () {
417
- sid , err := root .Serialize ()
418
- if err == nil {
419
- id := & mspprotos.SerializedIdentity {}
420
- err = proto .Unmarshal (sid , id )
421
- if err == nil {
422
- // check to see of this is an app org MSP
423
- if _ , ok := appOrgMSPs [k ]; ok {
424
- peerLogger .Debugf ("adding app root CAs for MSP [%s]" , k )
425
- appRootCAs = append (appRootCAs , id .IdBytes )
426
- } else {
427
- peerLogger .Debugf ("adding orderer root CAs for MSP [%s]" , k )
428
- ordererRootCAs = append (ordererRootCAs , id .IdBytes )
429
- }
430
- }
403
+ for _ , root := range v .GetTLSRootCerts () {
404
+ // check to see of this is an app org MSP
405
+ if _ , ok := appOrgMSPs [k ]; ok {
406
+ peerLogger .Debugf ("adding app root CAs for MSP [%s]" , k )
407
+ appRootCAs = append (appRootCAs , root )
408
+ } else {
409
+ peerLogger .Debugf ("adding orderer root CAs for MSP [%s]" , k )
410
+ ordererRootCAs = append (ordererRootCAs , root )
431
411
}
432
412
}
433
- for _ , intermediate := range v .GetIntermediateCerts () {
434
- sid , err := intermediate .Serialize ()
435
- if err == nil {
436
- id := & mspprotos.SerializedIdentity {}
437
- err = proto .Unmarshal (sid , id )
438
- if err == nil {
439
- // check to see of this is an app org MSP
440
- if _ , ok := appOrgMSPs [k ]; ok {
441
- peerLogger .Debugf ("adding app root CAs for MSP [%s]" , k )
442
- appRootCAs = append (appRootCAs , id .IdBytes )
443
- } else {
444
- peerLogger .Debugf ("adding orderer root CAs for MSP [%s]" , k )
445
- ordererRootCAs = append (ordererRootCAs , id .IdBytes )
446
- }
447
- }
413
+ for _ , intermediate := range v .GetTLSIntermediateCerts () {
414
+ // check to see of this is an app org MSP
415
+ if _ , ok := appOrgMSPs [k ]; ok {
416
+ peerLogger .Debugf ("adding app root CAs for MSP [%s]" , k )
417
+ appRootCAs = append (appRootCAs , intermediate )
418
+ } else {
419
+ peerLogger .Debugf ("adding orderer root CAs for MSP [%s]" , k )
420
+ ordererRootCAs = append (ordererRootCAs , intermediate )
448
421
}
449
422
}
450
423
}
0 commit comments