]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/tls: check if quic conn can send session ticket
authorAudi P. R. Putra <doelaudi@gmail.com>
Fri, 15 Sep 2023 18:23:51 +0000 (01:23 +0700)
committerSean Liao <sean@liao.dev>
Fri, 8 Aug 2025 16:59:24 +0000 (09:59 -0700)
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 <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
src/crypto/tls/quic.go
src/crypto/tls/quic_test.go

index ba8a235d84ad932684e5f6a588e6ede864d6419e..ed70100d11f0e7a87572378d8254b06efd1a7a32 100644 (file)
@@ -302,6 +302,9 @@ type QUICSessionTicketOptions struct {
 // Currently, it can only be called once.
 func (q *QUICConn) SendSessionTicket(opts QUICSessionTicketOptions) error {
        c := q.conn
+       if c.config.SessionTicketsDisabled {
+               return nil
+       }
        if !c.isHandshakeComplete.Load() {
                return quicError(errors.New("tls: SendSessionTicket called before handshake completed"))
        }
index 51cd4ef765dd6c189c6075d666333b497cb3e74a..f6e8c55d9d63e465b03412eef69e2daa1368d88a 100644 (file)
@@ -231,6 +231,18 @@ func TestQUICSessionResumption(t *testing.T) {
        if !cli2.conn.ConnectionState().DidResume {
                t.Errorf("second connection did not use session resumption")
        }
+
+       clientConfig.TLSConfig.SessionTicketsDisabled = true
+       cli3 := newTestQUICClient(t, clientConfig)
+       cli3.conn.SetTransportParameters(nil)
+       srv3 := newTestQUICServer(t, serverConfig)
+       srv3.conn.SetTransportParameters(nil)
+       if err := runTestQUICConnection(context.Background(), cli3, srv3, nil); err != nil {
+               t.Fatalf("error during third connection handshake: %v", err)
+       }
+       if cli3.conn.ConnectionState().DidResume {
+               t.Errorf("third connection unexpectedly used session resumption")
+       }
 }
 
 func TestQUICFragmentaryData(t *testing.T) {