Documentation
¶
Index ¶
- type Config
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) ConnectionState() ConnectionState
- func (c *Conn) Handshake() error
- func (c *Conn) HandshakeContext(ctx context.Context) error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) NetConn() net.Conn
- func (c *Conn) Read(p []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(p []byte) (int, error)
- type ConnectionState
- type Dialer
- type SessionCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ServerName is used for SNI and certificate hostname verification.
// When Dial/DialContext is called with a host:port, ServerName defaults to the host.
ServerName string
// NextProtos specifies the ALPN protocols to advertise.
// If nil, defaults to []string{"h2", "http/1.1"} to match Chrome.
// Set to an empty non-nil slice ([]string{}) to omit ALPN.
NextProtos []string
// RootCAs defines the root certificate authorities used to verify server certificates.
// If nil, Go's system root CAs are used.
RootCAs *x509.CertPool
// InsecureSkipVerify disables certificate chain and hostname verification.
// BoringSSL still verifies the TLS handshake CertificateVerify signature.
InsecureSkipVerify bool
// VerifyPeerCertificate, if non-nil, is called during certificate verification
// before Client Finished is sent (similar to crypto/tls.Config.VerifyPeerCertificate).
VerifyPeerCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
// NoPostQuantum disables the X25519MLKEM768 hybrid post-quantum key exchange group.
NoPostQuantum bool
// DisableALPS disables TLS ALPS (Application-Layer Protocol Settings) for "h2".
DisableALPS bool
// UseOldALPSCodepoint switches ALPS from the new codepoint (17613) to the legacy one (17513).
UseOldALPSCodepoint bool
// DisableECHGrease disables GREASE Encrypted Client Hello (ECH) extension.
DisableECHGrease bool
// DisableExtensionPermutation disables Chrome's TLS ClientHello extension permutation.
DisableExtensionPermutation bool
// ECHConfigList optionally sets a real ECHConfigList (overrides ECH GREASE).
ECHConfigList []byte
// TrustAnchorIDs optionally sets TLS Requested Trust Anchor IDs wire bytes.
TrustAnchorIDs []byte
// TLS13Only restricts the minimum TLS version to TLS 1.3 (default minimum is TLS 1.2).
TLS13Only bool
// ClientSessionCache enables TLS session resumption across connections.
ClientSessionCache SessionCache
// LibraryPath explicitly specifies the path to libchrometls.so/.dylib/.dll.
// If empty, auto-discovery checks CHROMETLS_LIB_PATH, executable dir,
// ./internal/bssl/lib, the platform-specific embedded library, and OS paths.
LibraryPath string
}
Config configures Chrome-like TLS handshakes performed via BoringSSL. All network I/O and application data framing remain fully controlled in Go.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a TLS connection whose handshake and record crypto are backed by Chrome's BoringSSL (via purego memory BIO) while all network I/O runs natively on the underlying Go net.Conn.
func DialWithDialer ¶
DialWithDialer connects using dialer and performs a Chrome TLS handshake. A nil dialer is equivalent to the zero-value net.Dialer.
func (*Conn) Close ¶
Close sends a best-effort TLS close_notify alert, closes the underlying net.Conn, and releases native BoringSSL resources.
func (*Conn) ConnectionState ¶
func (c *Conn) ConnectionState() ConnectionState
ConnectionState returns TLS connection details after the handshake completes.
func (*Conn) HandshakeContext ¶
HandshakeContext runs the Chrome TLS handshake, honoring ctx cancellation/deadline.
func (*Conn) RemoteAddr ¶
type ConnectionState ¶
type ConnectionState struct {
Version uint16
CipherSuite uint16
NegotiatedProtocol string
DidResume bool
ServerName string
PeerCertificates []*x509.Certificate
VerifiedChains [][]*x509.Certificate
}
ConnectionState records basic TLS details about an established Conn.
type Dialer ¶
type Dialer struct {
// NetDialer is the optional dialer used for underlying TCP connections.
// If nil, a zero-value net.Dialer is used.
NetDialer *net.Dialer
// Config specifies the Chrome TLS parameters. If nil, default Chrome 154
// parameters are used.
Config *Config
// contains filtered or unexported fields
}
Dialer dials network connections and establishes a Chrome-fingerprinted TLS session using BoringSSL (via purego) while keeping all network I/O in Go. Its shape matches crypto/tls.Dialer. The zero value is ready to use.
func (*Dialer) Client ¶
Client wraps an existing net.Conn as a Chrome-fingerprinted TLS client connection without immediately running the handshake (matching crypto/tls.Client).
func (*Dialer) Close ¶
Close releases the shared native SSL_CTX and prevents further use of the Dialer. Existing *Conn instances remain valid because BoringSSL reference-counts SSL_CTX.
type SessionCache ¶
type SessionCache interface {
Get(sessionKey string) (session []byte, ok bool)
Put(sessionKey string, session []byte)
}
SessionCache stores serialized BoringSSL TLS sessions keyed by host/session key to enable authentic Chrome TLS 1.3 PSK session resumption.
func NewLRUClientSessionCache ¶
func NewLRUClientSessionCache(capacity int) SessionCache
NewLRUClientSessionCache returns an in-memory LRU SessionCache. If capacity <= 0, a sensible default (64) is used.