Skip to content

Commit

Permalink
Merge pull request #34 from libp2p/no-key-error-check
Browse files Browse the repository at this point in the history
make the error check for not receiving a public key more explicit
  • Loading branch information
Stebalien authored Nov 12, 2019
2 parents 6b8d597 + ea13d7a commit 7c0aea2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions p2p/security/tls/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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 @@ -129,10 +132,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 7c0aea2

Please sign in to comment.