Skip to content

proposal: crypto/tls: pluggable Backend delegation to end ecosystem fragmentation #76997

Description

@rbqvq

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

  1. End Toolchain Fragmentation: Bring big-tech forks back to the official Go distribution.
  2. Allow users to use other TLS backends (e.g. OpenSSL, BoringSSL or other backend)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions