@cryptotaxi247 / kubo / commits / d04010476

handshake: setting remote key expects it to match

Juan Batiz-Benet committed Sep 19, 2014 at 05:00 UTC d040104762e7a862486343e2938dd6199e25861a
1 file changed +8 -1
crypto/spipe/handshake.go
+8 -1
@@ -87,11 +87,18 @@ func (s *SecurePipe) handshake() error {
87 return err
88 }
89
90 - s.remote.ID, err = IDFromPubKey(s.remote.PubKey)
90 + remoteID, err := IDFromPubKey(s.remote.PubKey)
91 if err != nil {
92 return err
93 }
94
95 + if s.remote.ID != nil && !remoteID.Equal(s.remote.ID) {
96 + e := "Expected pubkey does not match sent pubkey: %v - %v"
97 + return fmt.Errorf(e, s.remote.ID.Pretty(), remoteID.Pretty())
98 + } else if s.remote.ID == nil {
99 + s.remote.ID = remoteID
100 + }
101 +
102 exchange, err := selectBest(SupportedExchanges, proposeResp.GetExchanges())
103 if err != nil {
104 return err