Skip to content

DNS-over-TLS does not set ALPN to "dot" #510

Closed

Description

@ameshkov

DNS-over-TLS in dnsproxy does not set the ALPN protocol to "dot" in the TLS configuration. While this is not strictly required by RFC 7858, there are practical scenarios where it becomes necessary.

Problem

In upstream/dot.go, the tls.Config is constructed at line 61 without setting the NextProtos field to []string{"dot"}:

tlsConf: &tls.Config{
    ServerName:             addr.Hostname(),
    RootCAs:                opts.RootCAs,
    CipherSuites:           opts.CipherSuites,
    ClientSessionCache:     tls.NewLRUClientSessionCache(0),
    MinVersion:             tls.VersionTLS12,
    InsecureSkipVerify:     opts.InsecureSkipVerify,
    VerifyPeerCertificate:  opts.VerifyServerCertificate,
    VerifyConnection:       opts.VerifyConnection,
},

Why it matters

  1. RFC 8932 (Recommendations for DNS Privacy Service Operators) — references the "dot" ALPN value for DoT when deployed alongside DoH on the same IP address/port. Servers that serve both DoT and DoH on port 443 (like NextDNS) rely on ALPN to distinguish the two protocols.

  2. RFC 9461 (Service Binding Mapping for DNS Servers) — uses alpn=dot in SVCB/HTTPS DNS records to advertise DoT support. When connecting to such servers, the client should signal the "dot" ALPN to match what was advertised.

Practical impact

Some DNS-over-TLS providers (e.g., NextDNS on non-standard port 443) rely on ALPN to differentiate DoT from DoH traffic. Without the ALPN set to "dot", connections to such providers may fail or be misinterpreted.

You can reproduce it by configuring upstream to tls://dns.nextdns.io:443, it will only work with dot in ALPN it works.

Fix

Add NextProtos: []string{"dot"} to the tls.Config in newDoT():

tlsConf: &tls.Config{
    ServerName:             addr.Hostname(),
    RootCAs:                opts.RootCAs,
    CipherSuites:           opts.CipherSuites,
    ClientSessionCache:     tls.NewLRUClientSessionCache(0),
    MinVersion:             tls.VersionTLS12,
    InsecureSkipVerify:     opts.InsecureSkipVerify,
    VerifyPeerCertificate:  opts.VerifyServerCertificate,
    VerifyConnection:       opts.VerifyConnection,
    NextProtos:             []string{"dot"},
},

Activity

  1. added theissue type on Jul 7, 2026
  2. added
    bug
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions