Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-tls
Commits
333f6e05
Commit
333f6e05
authored
Apr 21, 2020
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve the error message returned when peer verification fails
parent
6d5ce188
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
crypto.go
crypto.go
+5
-1
transport_test.go
transport_test.go
+2
-1
No files found.
crypto.go
View file @
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
...
...
transport_test.go
View file @
333f6e05
...
...
@@ -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
())
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment