Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noise: don't fail handshake when early data is received without handler #1746

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions p2p/security/noise/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ func (s *secureSession) runHandshake(ctx context.Context) (err error) {
if err := s.earlyDataHandler.Received(ctx, s.insecureConn, initialPayload); err != nil {
return err
}
} else if len(initialPayload) > 0 {
return fmt.Errorf("received unexpected early data (%d bytes)", len(initialPayload))
}

// stage 1 //
Expand Down
10 changes: 5 additions & 5 deletions p2p/security/noise/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func TestEarlyDataRejected(t *testing.T) {
}
}

func TestEarlyDataRejectedWithNoHandler(t *testing.T) {
func TestEarlyDataAcceptedWithNoHandler(t *testing.T) {
clientEDH := &earlyDataHandler{
send: func(ctx context.Context, conn net.Conn, id peer.ID) []byte { return []byte("foobar") },
}
Expand All @@ -526,14 +526,14 @@ func TestEarlyDataRejectedWithNoHandler(t *testing.T) {
errChan <- err
}()

_, err = initTransport.SecureOutbound(context.Background(), respConn, respTransport.localID)
require.Error(t, err)
conn, err := initTransport.SecureOutbound(context.Background(), respConn, respTransport.localID)
require.NoError(t, err)
defer conn.Close()

select {
case <-time.After(500 * time.Millisecond):
t.Fatal("timeout")
case err := <-errChan:
require.Error(t, err)
require.Contains(t, err.Error(), "received unexpected early data")
require.NoError(t, err)
}
}