mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 <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>
This commit is contained in:
parent
bdb2d50fdf
commit
a8dd771e13
2 changed files with 15 additions and 0 deletions
|
|
@ -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"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue