Skip to content

Commit

Permalink
[FAB-17095] MCS not to print identities as bytes
Browse files Browse the repository at this point in the history
The messageCryptoService prints identities as decimal bytes,
and this doesn't help much with debugging because no sane person
would want to convert a decimal byte array to a PEM manually
and then pass it through openssl to figure out what is the peer
in question.

This change set makes the logs use the String() method
of the PeerIdentityType.

Change-Id: I71706d6d941de3a9fe7d6efbadf28949142232e2
Signed-off-by: yacovm <[email protected]>
  • Loading branch information
yacovm committed Nov 15, 2019
1 parent 0cd1107 commit 6cd02a6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/peer/gossip/mcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *MSPMessageCryptoService) GetPKIidOfCert(peerIdentity api.PeerIdentityTy

sid, err := s.deserializer.Deserialize(peerIdentity)
if err != nil {
mcsLogger.Errorf("Failed getting validated identity from peer identity [% x]: [%s]", peerIdentity, err)
mcsLogger.Errorf("Failed getting validated identity from peer identity %s: [%s]", peerIdentity, err)

return nil
}
Expand All @@ -111,7 +111,7 @@ func (s *MSPMessageCryptoService) GetPKIidOfCert(peerIdentity api.PeerIdentityTy
// Hash
digest, err := s.hasher.Hash(raw, &bccsp.SHA256Opts{})
if err != nil {
mcsLogger.Errorf("Failed computing digest of serialized identity [% x]: [%s]", peerIdentity, err)
mcsLogger.Errorf("Failed computing digest of serialized identity %s: [%s]", peerIdentity, err)
return nil
}

Expand Down Expand Up @@ -312,7 +312,7 @@ func (s *MSPMessageCryptoService) getValidatedIdentity(peerIdentity api.PeerIden
// Deserialize identity
identity, err := mspManager.DeserializeIdentity([]byte(peerIdentity))
if err != nil {
mcsLogger.Debugf("Failed deserialization identity [% x] on [%s]: [%s]", peerIdentity, chainID, err)
mcsLogger.Debugf("Failed deserialization identity %s on [%s]: [%s]", peerIdentity, chainID, err)
continue
}

Expand All @@ -327,14 +327,14 @@ func (s *MSPMessageCryptoService) getValidatedIdentity(peerIdentity api.PeerIden
// This will be done by the caller function, if needed.

if err := identity.Validate(); err != nil {
mcsLogger.Debugf("Failed validating identity [% x] on [%s]: [%s]", peerIdentity, chainID, err)
mcsLogger.Debugf("Failed validating identity %s on [%s]: [%s]", peerIdentity, chainID, err)
continue
}

mcsLogger.Debugf("Validation succeeded [% x] on [%s]", peerIdentity, chainID)
mcsLogger.Debugf("Validation succeeded %s on [%s]", peerIdentity, chainID)

return identity, common.ChannelID(chainID), nil
}

return nil, nil, fmt.Errorf("Peer Identity [% x] cannot be validated. No MSP found able to do that.", peerIdentity)
return nil, nil, fmt.Errorf("Peer Identity %s cannot be validated. No MSP found able to do that.", peerIdentity)
}

0 comments on commit 6cd02a6

Please sign in to comment.