Skip to content

Commit a915b99

Browse files
committed
crypto/tls: change SendSessionTicket to take an options struct
To allow for future evolution of the API, make QUICConn.SendSessionTicket take a QUICSessionTicketOptions rather than a single bool. For #60107 Change-Id: I798fd0feec5c7581e3c3574e2de99611c81df47f Reviewed-on: https://go-review.googlesource.com/c/go/+/514997 Reviewed-by: Roland Shoemaker <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Marten Seemann <[email protected]>
1 parent a09ea59 commit a915b99

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

api/go1.21.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ pkg crypto/tls, method (*QUICConn) Close() error #44886
6060
pkg crypto/tls, method (*QUICConn) ConnectionState() ConnectionState #44886
6161
pkg crypto/tls, method (*QUICConn) HandleData(QUICEncryptionLevel, []uint8) error #44886
6262
pkg crypto/tls, method (*QUICConn) NextEvent() QUICEvent #44886
63-
pkg crypto/tls, method (*QUICConn) SendSessionTicket(bool) error #60107
63+
pkg crypto/tls, method (*QUICConn) SendSessionTicket(QUICSessionTicketOptions) error #60107
64+
pkg crypto/tls, type QUICSessionTicketOptions struct #60107
65+
pkg crypto/tls, type QUICSessionTicketOptions struct, EarlyData bool #60107
6466
pkg crypto/tls, method (*QUICConn) SetTransportParameters([]uint8) #44886
6567
pkg crypto/tls, method (*QUICConn) Start(context.Context) error #44886
6668
pkg crypto/tls, method (QUICEncryptionLevel) String() string #44886

src/crypto/tls/quic.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,15 @@ func (q *QUICConn) HandleData(level QUICEncryptionLevel, data []byte) error {
246246
return nil
247247
}
248248

249+
type QUICSessionTicketOptions struct {
250+
// EarlyData specifies whether the ticket may be used for 0-RTT.
251+
EarlyData bool
252+
}
253+
249254
// SendSessionTicket sends a session ticket to the client.
250255
// It produces connection events, which may be read with NextEvent.
251256
// Currently, it can only be called once.
252-
func (q *QUICConn) SendSessionTicket(earlyData bool) error {
257+
func (q *QUICConn) SendSessionTicket(opts QUICSessionTicketOptions) error {
253258
c := q.conn
254259
if !c.isHandshakeComplete.Load() {
255260
return quicError(errors.New("tls: SendSessionTicket called before handshake completed"))
@@ -261,7 +266,7 @@ func (q *QUICConn) SendSessionTicket(earlyData bool) error {
261266
return quicError(errors.New("tls: SendSessionTicket called multiple times"))
262267
}
263268
q.sessionTicketSent = true
264-
return quicError(c.sendSessionTicket(earlyData))
269+
return quicError(c.sendSessionTicket(opts.EarlyData))
265270
}
266271

267272
// ConnectionState returns basic TLS details about the connection.

src/crypto/tls/quic_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ func runTestQUICConnection(ctx context.Context, cli, srv *testQUICConn, onHandle
125125
case QUICHandshakeDone:
126126
a.complete = true
127127
if a == srv {
128-
if err := srv.conn.SendSessionTicket(false); err != nil {
128+
opts := QUICSessionTicketOptions{}
129+
if err := srv.conn.SendSessionTicket(opts); err != nil {
129130
return err
130131
}
131132
}

0 commit comments

Comments
 (0)