Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 8afeaef

Browse files
authored
Merge pull request #34 from libp2p/no-key-error-check
make the error check for not receiving a public key more explicit
2 parents 141af4b + 27e03a0 commit 8afeaef

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

transport.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ func (t *Transport) handshake(
116116
case remotePubKey = <-keyCh:
117117
default:
118118
}
119+
if remotePubKey == nil {
120+
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
121+
}
119122

120123
conn, err := t.setupConn(tlsConn, remotePubKey)
121124
if err != nil {
@@ -129,10 +132,6 @@ func (t *Transport) handshake(
129132
}
130133

131134
func (t *Transport) setupConn(tlsConn *tls.Conn, remotePubKey ci.PubKey) (sec.SecureConn, error) {
132-
if remotePubKey == nil {
133-
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
134-
}
135-
136135
remotePeerID, err := peer.IDFromPublicKey(remotePubKey)
137136
if err != nil {
138137
return nil, err

0 commit comments

Comments
 (0)