mirror of
https://github.com/XTLS/REALITY.git
synced 2026-09-27 01:10:18 +03:00
crypto/tls: expose extensions presented by client to GetCertificate
This enables JA3 and JA4 TLS fingerprinting to be implemented from the GetCertificate callback, similar to what BoringSSL provides with its SSL_CTX_set_dos_protection_cb hook. fixes #32936 Change-Id: Idb54ebcb43075582fcef0ac6438727f494543424 Reviewed-on: https://go-review.googlesource.com/c/go/+/471396 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
@@ -446,6 +446,10 @@ type ClientHelloInfo struct {
|
||||
// might be rejected if used.
|
||||
SupportedVersions []uint16
|
||||
|
||||
// Extensions lists the IDs of the extensions presented by the client
|
||||
// in the client hello.
|
||||
Extensions []uint16
|
||||
|
||||
// Conn is the underlying net.Conn for the connection. Do not read
|
||||
// from, or write to, this connection; that will cause the TLS
|
||||
// connection to fail.
|
||||
|
||||
@@ -97,6 +97,8 @@ type clientHelloMsg struct {
|
||||
pskBinders [][]byte
|
||||
quicTransportParameters []byte
|
||||
encryptedClientHello []byte
|
||||
// extensions are only populated on the server-side of a handshake
|
||||
extensions []uint16
|
||||
}
|
||||
|
||||
func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) {
|
||||
@@ -467,6 +469,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
|
||||
return false
|
||||
}
|
||||
seenExts[extension] = true
|
||||
m.extensions = append(m.extensions, extension)
|
||||
|
||||
switch extension {
|
||||
case extensionServerName:
|
||||
|
||||
@@ -949,6 +949,7 @@ func clientHelloInfo(ctx context.Context, c *Conn, clientHello *clientHelloMsg)
|
||||
SignatureSchemes: clientHello.supportedSignatureAlgorithms,
|
||||
SupportedProtos: clientHello.alpnProtocols,
|
||||
SupportedVersions: supportedVersions,
|
||||
Extensions: clientHello.extensions,
|
||||
Conn: c.conn,
|
||||
config: c.config,
|
||||
ctx: ctx,
|
||||
|
||||
Reference in New Issue
Block a user