@@ -213,28 +213,72 @@ var testingOnlyForceDowngradeCanary bool
213
213
214
214
// ConnectionState records basic TLS details about the connection.
215
215
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
227
218
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
230
244
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.
237
278
TLSUnique []byte
279
+
280
+ // ekm is a closure exposed via ExportKeyingMaterial.
281
+ ekm func (label string , context []byte , length int ) ([]byte , error )
238
282
}
239
283
240
284
// ExportKeyingMaterial returns length bytes of exported key material in a new
0 commit comments