Skip to content

Commit a8dd771

Browse files
ronaudinhoseankhliao
authored andcommitted
crypto/tls: check if quic conn can send session ticket
On SendSessionTicket, returns nil if SessionTicketsDisabled is disabled in config. Fixes #62032 Change-Id: Id0c89e2e6fb0805bbf108bb0cafdabdfbaf3897f Reviewed-on: https://go-review.googlesource.com/c/go/+/528755 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Mark Freeman <[email protected]>
1 parent bdb2d50 commit a8dd771

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/crypto/tls/quic.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ type QUICSessionTicketOptions struct {
302302
// Currently, it can only be called once.
303303
func (q *QUICConn) SendSessionTicket(opts QUICSessionTicketOptions) error {
304304
c := q.conn
305+
if c.config.SessionTicketsDisabled {
306+
return nil
307+
}
305308
if !c.isHandshakeComplete.Load() {
306309
return quicError(errors.New("tls: SendSessionTicket called before handshake completed"))
307310
}

src/crypto/tls/quic_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ func TestQUICSessionResumption(t *testing.T) {
231231
if !cli2.conn.ConnectionState().DidResume {
232232
t.Errorf("second connection did not use session resumption")
233233
}
234+
235+
clientConfig.TLSConfig.SessionTicketsDisabled = true
236+
cli3 := newTestQUICClient(t, clientConfig)
237+
cli3.conn.SetTransportParameters(nil)
238+
srv3 := newTestQUICServer(t, serverConfig)
239+
srv3.conn.SetTransportParameters(nil)
240+
if err := runTestQUICConnection(context.Background(), cli3, srv3, nil); err != nil {
241+
t.Fatalf("error during third connection handshake: %v", err)
242+
}
243+
if cli3.conn.ConnectionState().DidResume {
244+
t.Errorf("third connection unexpectedly used session resumption")
245+
}
234246
}
235247

236248
func TestQUICFragmentaryData(t *testing.T) {

0 commit comments

Comments
 (0)