netxlite: utls for TLS parroting
This is the ground work for https://github.com/ooni/probe/issues/1424.
This commit is contained in:
parent
17bfb052c5
commit
285290a98d
3 changed files with 56 additions and 0 deletions
|
|
@ -5,6 +5,8 @@ import (
|
|||
"crypto/tls"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
utls "gitlab.com/yawning/utls.git"
|
||||
)
|
||||
|
||||
// TLSHandshaker is the generic TLS handshaker.
|
||||
|
|
@ -105,4 +107,41 @@ func (h *TLSHandshakerLogger) Handshake(
|
|||
return tlsconn, state, nil
|
||||
}
|
||||
|
||||
// UTLSConn implements TLSConn and uses a utls UConn as its underlying connection
|
||||
type UTLSConn struct {
|
||||
*utls.UConn
|
||||
}
|
||||
|
||||
// NewConnUTLS creates a NewConn function creating a utls connection with a specified ClientHelloID
|
||||
func NewConnUTLS(clientHello *utls.ClientHelloID) func(conn net.Conn, config *tls.Config) TLSConn {
|
||||
return func(conn net.Conn, config *tls.Config) TLSConn {
|
||||
uConfig := &utls.Config{
|
||||
RootCAs: config.RootCAs,
|
||||
NextProtos: config.NextProtos,
|
||||
ServerName: config.ServerName,
|
||||
InsecureSkipVerify: config.InsecureSkipVerify,
|
||||
DynamicRecordSizingDisabled: config.DynamicRecordSizingDisabled,
|
||||
}
|
||||
tlsConn := utls.UClient(conn, uConfig, *clientHello)
|
||||
return &UTLSConn{tlsConn}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *UTLSConn) ConnectionState() tls.ConnectionState {
|
||||
uState := c.Conn.ConnectionState()
|
||||
return tls.ConnectionState{
|
||||
Version: uState.Version,
|
||||
HandshakeComplete: uState.HandshakeComplete,
|
||||
DidResume: uState.DidResume,
|
||||
CipherSuite: uState.CipherSuite,
|
||||
NegotiatedProtocol: uState.NegotiatedProtocol,
|
||||
ServerName: uState.ServerName,
|
||||
PeerCertificates: uState.PeerCertificates,
|
||||
VerifiedChains: uState.VerifiedChains,
|
||||
SignedCertificateTimestamps: uState.SignedCertificateTimestamps,
|
||||
OCSPResponse: uState.OCSPResponse,
|
||||
TLSUnique: uState.TLSUnique,
|
||||
}
|
||||
}
|
||||
|
||||
var _ TLSHandshaker = &TLSHandshakerLogger{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue