Skip to content

Commit 66cb673

Browse files
committed
crypto/tls: expand the ConnectionState docs
Fixes #37572 Change-Id: I493392f535a979ee16609861041da2ecfe21cf77 Reviewed-on: https://go-review.googlesource.com/c/go/+/239744 Run-TryBot: Filippo Valsorda <[email protected]> Reviewed-by: Katie Hockman <[email protected]>
1 parent 3c6fec8 commit 66cb673

File tree

1 file changed

+63
-19
lines changed

1 file changed

+63
-19
lines changed

src/crypto/tls/common.go

+63-19
Original file line numberDiff line numberDiff line change
@@ -213,28 +213,72 @@ var testingOnlyForceDowngradeCanary bool
213213

214214
// ConnectionState records basic TLS details about the connection.
215215
type ConnectionState struct {
216-
Version uint16 // TLS version used by the connection (e.g. VersionTLS12)
217-
HandshakeComplete bool // TLS handshake is complete
218-
DidResume bool // connection resumes a previous TLS connection
219-
CipherSuite uint16 // cipher suite in use (TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, ...)
220-
NegotiatedProtocol string // negotiated next protocol (not guaranteed to be from Config.NextProtos)
221-
NegotiatedProtocolIsMutual bool // negotiated protocol was advertised by server (client side only)
222-
ServerName string // server name requested by client, if any
223-
PeerCertificates []*x509.Certificate // certificate chain presented by remote peer
224-
VerifiedChains [][]*x509.Certificate // verified chains built from PeerCertificates
225-
SignedCertificateTimestamps [][]byte // SCTs from the peer, if any
226-
OCSPResponse []byte // stapled OCSP response from peer, if any
216+
// Version is the TLS version used by the connection (e.g. VersionTLS12).
217+
Version uint16
227218

228-
// ekm is a closure exposed via ExportKeyingMaterial.
229-
ekm func(label string, context []byte, length int) ([]byte, error)
219+
// HandshakeComplete is true if the handshake has concluded.
220+
HandshakeComplete bool
221+
222+
// DidResume is true if this connection was successfully resumed from a
223+
// previous session with a session ticket or similar mechanism.
224+
DidResume bool
225+
226+
// CipherSuite is the cipher suite negotiated for the connection (e.g.
227+
// TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_AES_128_GCM_SHA256).
228+
CipherSuite uint16
229+
230+
// NegotiatedProtocol is the application protocol negotiated with ALPN.
231+
//
232+
// Note that on the client side, this is currently not guaranteed to be from
233+
// Config.NextProtos.
234+
NegotiatedProtocol string
235+
236+
// NegotiatedProtocolIsMutual used to indicate a mutual NPN negotiation.
237+
//
238+
// Deprecated: this value is always true.
239+
NegotiatedProtocolIsMutual bool
240+
241+
// ServerName is the value of the Server Name Indication extension sent by
242+
// the client. It's available both on the server and on the client side.
243+
ServerName string
230244

231-
// TLSUnique contains the "tls-unique" channel binding value (see RFC
232-
// 5929, section 3). For resumed sessions this value will be nil
233-
// because resumption does not include enough context (see
234-
// https://mitls.org/pages/attacks/3SHAKE#channelbindings). This will
235-
// change in future versions of Go once the TLS master-secret fix has
236-
// been standardized and implemented. It is not defined in TLS 1.3.
245+
// PeerCertificates are the parsed certificates sent by the peer, in the
246+
// order in which they were sent. The first element is the leaf certificate
247+
// that the connection is verified against.
248+
//
249+
// On the client side, it can't be empty. On the server side, it can be
250+
// empty if Config.ClientAuth is not RequireAnyClientCert or
251+
// RequireAndVerifyClientCert.
252+
PeerCertificates []*x509.Certificate
253+
254+
// VerifiedChains is a list of one or more chains where the first element is
255+
// PeerCertificates[0] and the last element is from Config.RootCAs (on the
256+
// client side) or Config.ClientCAs (on the server side).
257+
//
258+
// On the client side, it's set if Config.InsecureSkipVerify is false. On
259+
// the server side, it's set if Config.ClientAuth is VerifyClientCertIfGiven
260+
// (and the peer provided a certificate) or RequireAndVerifyClientCert.
261+
VerifiedChains [][]*x509.Certificate
262+
263+
// SignedCertificateTimestamps is a list of SCTs provided by the peer
264+
// through the TLS handshake for the leaf certificate, if any.
265+
SignedCertificateTimestamps [][]byte
266+
267+
// OCSPResponse is a stapled Online Certificate Status Protocol (OCSP)
268+
// response provided by the peer for the leaf certificate, if any.
269+
OCSPResponse []byte
270+
271+
// TLSUnique contains the "tls-unique" channel binding value (see RFC 5929,
272+
// Section 3). This value will be nil for TLS 1.3 connections and for all
273+
// resumed connections.
274+
//
275+
// Deprecated: there are conditions in which this value might not be unique
276+
// to a connection. See the Security Considerations sections of RFC 5705 and
277+
// RFC 7627, and https://mitls.org/pages/attacks/3SHAKE#channelbindings.
237278
TLSUnique []byte
279+
280+
// ekm is a closure exposed via ExportKeyingMaterial.
281+
ekm func(label string, context []byte, length int) ([]byte, error)
238282
}
239283

240284
// ExportKeyingMaterial returns length bytes of exported key material in a new

0 commit comments

Comments
 (0)