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

Commit

Permalink
make the error check for not receiving a public key more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 1, 2019
1 parent 46e9e9f commit 27e03a0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ func (t *Transport) handshake(
case remotePubKey = <-keyCh:
default:
}
if remotePubKey == nil {
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
}

conn, err := t.setupConn(tlsConn, remotePubKey)
if err != nil {
Expand All @@ -118,10 +121,6 @@ func (t *Transport) handshake(
}

func (t *Transport) setupConn(tlsConn *tls.Conn, remotePubKey ci.PubKey) (sec.SecureConn, error) {
if remotePubKey == nil {
return nil, errors.New("go-libp2p-tls BUG: expected remote pub key to be set")
}

remotePeerID, err := peer.IDFromPublicKey(remotePubKey)
if err != nil {
return nil, err
Expand Down

0 comments on commit 27e03a0

Please sign in to comment.