Skip to content
Open
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
7 changes: 7 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ const (
// include downgrade canaries even if it's using its highers supported version.
var testingOnlyForceDowngradeCanary bool

// ConnectionMetrics contains basic metrics about the connection.
type ConnectionMetrics struct {
// ClientSentTicket is true if the client has sent a TLS 1.2 session ticket
// or a TLS 1.3 PSK in the ClientHello successfully.
ClientSentTicket bool
}

// ConnectionState records basic TLS details about the connection.
type ConnectionState struct {
// Version is the TLS version used by the connection (e.g. VersionTLS12).
Expand Down
10 changes: 10 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Conn struct {
// zero or one.
handshakes int
extMasterSecret bool
clientSentTicket bool // whether the client sent a session ticket or a PSK in the Client Hello
didResume bool // whether this connection was a session resumption
didHRR bool // whether a HelloRetryRequest was sent/received
cipherSuite uint16
Expand Down Expand Up @@ -1699,3 +1700,12 @@ func (c *Conn) VerifyHostname(host string) error {
}
return c.peerCertificates[0].VerifyHostname(host)
}

// ConnectionMetrics returns basic metrics about the connection.
func (c *Conn) ConnectionMetrics() ConnectionMetrics {
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
var metrics ConnectionMetrics
metrics.ClientSentTicket = c.clientSentTicket
return metrics
}
5 changes: 5 additions & 0 deletions u_handshake_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ func (c *UConn) clientHandshake(ctx context.Context) (err error) {
return err
}

// Client sent a session ticket or PSK.
if session != nil {
c.clientSentTicket = true
}

if hello.earlyData {
suite := cipherSuiteTLS13ByID(session.cipherSuite)
transcript := suite.hash.New()
Expand Down