ECH — Xray-core
Encrypted Client Hello (ECH) hides the SNI from on-path observers by encrypting the ClientHello with a server-published public key. Xray exposes ECH as three fields on the standard tlsSettings block — no separate ECH struct.
Configuration
ECH lives on streamSettings.tlsSettings:
| Field | Side | Type | Default | Allowed | Description |
|---|---|---|---|---|---|
echServerKeys | Inbound | string | (unset) | base64 ECH key bundle | Server ECH key set. Generate alongside your TLS cert. |
echConfigList | Outbound | string | (unset) | base64 ECHConfigList, or a DNS URL (https://…, h2c://…, udp://…, optionally <domain>+<URL>) | Enables ECH on the client: either the config list itself, or a DNS server to fetch it from the HTTPS record of serverName (or of <domain>). Unset means no ECH. |
echSockopt | Outbound | SocketConfig | (unset) | socket options | Socket options applied to the ECH-discovery DNS request. |
Examples
Inbound — serve ECH alongside regular TLS:
{
"streamSettings": {
"security": "tls",
"tlsSettings": {
"serverName": "example.com",
"certificates": [{ "certificateFile": "/etc/ssl/cert.pem", "keyFile": "/etc/ssl/key.pem" }],
"echServerKeys": "<base64 ECHConfigList + private keys>"
}
}
}Outbound — fetch the ECH config from the HTTPS DNS record of serverName:
{
"streamSettings": {
"security": "tls",
"tlsSettings": {
"serverName": "example.com",
"alpn": ["h2", "http/1.1"],
"echConfigList": "https://1.1.1.1/dns-query"
}
}
}Xray queries the HTTPS record of serverName through that DNS server (write <domain>+<URL> to look up another name) and uses the published config. ECH is not opportunistic: without echConfigList the client sends a plain ClientHello, and when the lookup fails the connection fails instead of falling back to plain TLS.
Outbound — pin a specific ECH config:
{
"streamSettings": {
"security": "tls",
"tlsSettings": {
"serverName": "example.com",
"echConfigList": "<base64 ECHConfigList>"
}
}
}Notes
- ECH requires TLS 1.3. Set
minVersion: "1.3"if you want to enforce it at the protocol layer. - The ECH
serverNamevalue (example.comabove) is the public name — the SNI visible on the wire. TheinnerServerName (the one ECH encrypts) is derived from the request's actual destination. - Pin a base64
echConfigListonly when you control both ends. A DNS URL is more robust because the published config can rotate without reconfiguring the client.
Cross-core notes
- sing-box has dedicated
InboundECHOptionsandOutboundECHOptionsstructs undertls.ech. See ECH — sing-box. - mihomo exposes a per-proxy
ech-optsblock with three fields (enable,config,query-server-name). See ECH — mihomo.
Source: infra/conf/transport_security.go:316-318 · v26.11.9 (676eaf6)
