Unverified Commit 8afeaef8 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #34 from libp2p/no-key-error-check

make the error check for not receiving a public key more explicit
parents 141af4b2 27e03a0a
...@@ -116,6 +116,9 @@ func (t *Transport) handshake( ...@@ -116,6 +116,9 @@ func (t *Transport) handshake(
case remotePubKey = <-keyCh: case remotePubKey = <-keyCh:
default: 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) conn, err := t.setupConn(tlsConn, remotePubKey)
if err != nil { if err != nil {
...@@ -129,10 +132,6 @@ func (t *Transport) handshake( ...@@ -129,10 +132,6 @@ func (t *Transport) handshake(
} }
func (t *Transport) setupConn(tlsConn *tls.Conn, remotePubKey ci.PubKey) (sec.SecureConn, error) { 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) remotePeerID, err := peer.IDFromPublicKey(remotePubKey)
if err != nil { if err != nil {
return nil, err return nil, err
......
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