Unverified Commit 8a8ad624 authored by Marten Seemann's avatar Marten Seemann Committed by GitHub

Merge pull request #57 from libp2p/improve-verification-error

improve the error message returned when peer verification fails
parents 6d5ce188 333f6e05
......@@ -93,7 +93,11 @@ func (i *Identity) ConfigForPeer(remote peer.ID) (*tls.Config, <-chan ic.PubKey)
return err
}
if remote != "" && !remote.MatchesPublicKey(pubKey) {
return errors.New("peer IDs don't match")
peerID, err := peer.IDFromPublicKey(pubKey)
if err != nil {
peerID = peer.ID(fmt.Sprintf("(not determined: %s)", err.Error()))
}
return fmt.Errorf("peer IDs don't match: expected %s, got %s", remote, peerID)
}
keyCh <- pubKey
return nil
......
......@@ -184,7 +184,8 @@ var _ = Describe("Transport", func() {
}()
// dial, but expect the wrong peer ID
_, err = clientTransport.SecureOutbound(context.Background(), clientInsecureConn, thirdPartyID)
Expect(err).To(MatchError("peer IDs don't match"))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("peer IDs don't match"))
Eventually(done).Should(BeClosed())
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment