Proposal Details
Abstract
The current monolithic architecture of crypto/tls has led to significant ecosystem fragmentation, with high-performance users (e.g., Cloudflare) being forced to maintain private Go toolchain patches to implement features like Delegated Credentials.
This proposal introduces a delegation mechanism within tls.Conn to support alternative backends.
This "escape hatch" allows the standard library to remain the unified interface for Go networking while enabling industry-leading performance or feature without the need for custom toolchain forks.
Background
Go's net/http and other core libraries are hard-coupled to *tls.Conn.
This coupling, combined with the slow evolution of the standard TLS stack, has created a "Performance Gap"
Users shouldn't have to wait for Go 2 to achieve modern networking efficiency.
Proposed Changes
1. The AlternativeConn Interface
A exported interface that maps to the functional requirements of a TLS connection.
2. The alternativeConn wrapper
Adding an alt field to tls.Conn.
If set, tls.Conn acts as a transparent proxy to the backend.
type AlternativeConn interface {
net.Conn
ConnectionState() ConnectionState
... // all exists method on tls.Conn
}
type Conn struct {
alt AlternativeConn
// ... existing fields
}
func (c *Conn) Read(p []byte) (int, error) {
if c.alt != nil {
return c.alt.Read(p)
}
...
}
3. Factory Method
func NewAltConn(alt AlternativeConn) *tls.Conn
func NewAltQUICConn(alt AlternativeQUICConn) *tls.QUICConn
This allows any third-party library to be used as a *tls.Conn compatible with the entire Go ecosystem.
Rationale
- End Toolchain Fragmentation: Bring big-tech forks back to the official Go distribution.
- Allow users to use other TLS backends (e.g. OpenSSL, BoringSSL or other backend)
- Allow us to add experimental packages to the draft RFC (
golang.org/x/crypto/tls)
Note
The proposal committee may choose to accept or reject of this proposal.
However, providing a pluggable interface is the most backward-compatible way to evolve Go's networking capabilities.
Proposal Details
Abstract
The current monolithic architecture of
crypto/tlshas led to significant ecosystem fragmentation, with high-performance users (e.g., Cloudflare) being forced to maintain private Go toolchain patches to implement features like Delegated Credentials.This proposal introduces a delegation mechanism within
tls.Connto support alternative backends.This "escape hatch" allows the standard library to remain the unified interface for Go networking while enabling industry-leading performance or feature without the need for custom toolchain forks.
Background
Go's
net/httpand other core libraries are hard-coupled to*tls.Conn.This coupling, combined with the slow evolution of the standard TLS stack, has created a "Performance Gap"
Users shouldn't have to wait for Go 2 to achieve modern networking efficiency.
Proposed Changes
1. The
AlternativeConnInterfaceA exported interface that maps to the functional requirements of a TLS connection.
2. The
alternativeConnwrapperAdding an
altfield totls.Conn.If set,
tls.Connacts as a transparent proxy to the backend.3. Factory Method
This allows any third-party library to be used as a *tls.Conn compatible with the entire Go ecosystem.
Rationale
golang.org/x/crypto/tls)Note
The proposal committee may choose to accept or reject of this proposal.
However, providing a pluggable interface is the most backward-compatible way to evolve Go's networking capabilities.