Skip to content

Commit c7b3fe0

Browse files
committed
Enable to bypass gossip security identity checks
In order to enable peer to connect to the organization leaders using same certificate adding a new configuration key which allows bypassing identity verification. Following parameter has to be added to the list of env variables or core.yaml: - CORE_PEER_GOSSIP_IGNORESECURITY=true Change-Id: I2cc18f290f1d36ad3900fe3ded4997fbc3d885c5 Signed-off-by: Artem Barger <[email protected]>
1 parent 0c2dff7 commit c7b3fe0

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

gossip/integration/integration.go

+41
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ import (
2121
"strings"
2222
"time"
2323

24+
"github.com/hyperledger/fabric/gossip/api"
25+
"github.com/hyperledger/fabric/gossip/common"
2426
"github.com/hyperledger/fabric/gossip/gossip"
2527
"github.com/hyperledger/fabric/peer/gossip/mcs"
2628
"github.com/hyperledger/fabric/peer/gossip/sa"
29+
"github.com/spf13/viper"
2730
"google.golang.org/grpc"
2831
)
2932

@@ -58,5 +61,43 @@ func NewGossipComponent(identity []byte, endpoint string, s *grpc.Server, dialOp
5861
conf := newConfig(endpoint, bootPeers...)
5962
cryptSvc := mcs.NewMessageCryptoService()
6063
secAdv := sa.NewSecurityAdvisor()
64+
if viper.GetBool("peer.gossip.ignoresecurity") {
65+
sec := &secImpl{[]byte(endpoint)}
66+
cryptSvc = sec
67+
secAdv = sec
68+
identity = []byte(endpoint)
69+
}
6170
return gossip.NewGossipService(conf, s, secAdv, cryptSvc, identity, dialOpts...)
6271
}
72+
73+
type secImpl struct {
74+
identity []byte
75+
}
76+
77+
func (*secImpl) OrgByPeerIdentity(api.PeerIdentityType) api.OrgIdentityType {
78+
return api.OrgIdentityType("DEFAULT")
79+
}
80+
81+
func (s *secImpl) GetPKIidOfCert(peerIdentity api.PeerIdentityType) common.PKIidType {
82+
return common.PKIidType(peerIdentity)
83+
}
84+
85+
func (s *secImpl) VerifyBlock(chainID common.ChainID, signedBlock api.SignedBlock) error {
86+
return nil
87+
}
88+
89+
func (s *secImpl) Sign(msg []byte) ([]byte, error) {
90+
return msg, nil
91+
}
92+
93+
func (s *secImpl) Verify(peerIdentity api.PeerIdentityType, signature, message []byte) error {
94+
return nil
95+
}
96+
97+
func (s *secImpl) VerifyByChannel(chainID common.ChainID, peerIdentity api.PeerIdentityType, signature, message []byte) error {
98+
return nil
99+
}
100+
101+
func (s *secImpl) ValidateIdentity(peerIdentity api.PeerIdentityType) error {
102+
return nil
103+
}

peer/common/anchors.go

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/hyperledger/fabric/msp"
2929
"github.com/hyperledger/fabric/protos/peer"
30+
"github.com/spf13/viper"
3031
)
3132

3233
type AnchorPeerParser struct {
@@ -126,6 +127,11 @@ func anchorPeerFromFile(filename string) (*peer.AnchorPeer, error) {
126127
Port: int32(port),
127128
Cert: identity,
128129
}
130+
131+
if viper.GetBool("peer.gossip.ignoresecurity") {
132+
ap.Cert = []byte(fmt.Sprintf("%s:%d", ap.Host, ap.Port))
133+
}
134+
129135
return ap, nil
130136
}
131137

0 commit comments

Comments
 (0)