English
The tls block
Enables TLS on an inbound or outbound. The presence of the block already means "enabled"; enabled cannot be written. The server name is sni (not server_name: the loader rejects that field).
Which protocols take the block is in the table. TLS is mandatory for trojan (inbound and outbound), anytls (outbound), hysteria, hysteria2, tuic. REALITY is described separately: reality.md.
Outbound (client)
| Field | Type | Default | Meaning |
|---|---|---|---|
sni | string | the server address | The server name in the ClientHello and for certificate verification |
disable_sni | bool | false | Do not send SNI; the certificate is still verified against the name |
insecure | bool | false | Do not verify the certificate chain |
alpn | string or list | — | ALPN; with the field empty the transport supplies its own (h2 for gRPC and so on) |
min_version, max_version | "1.2", "1.3" | 1.2 … 1.3 | The version range; 1.0 and 1.1 are an error: TLS below 1.2 is not supported |
cipher_suites | list | the rustls set | TLS 1.2 cipher suites by Go names (TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, …); TLS 1.3 suites are always on |
curve_preferences | list | X25519MLKEM768, X25519, P256, P384 | Key exchange groups in order; P521 is not supported |
certificate, certificate_path | PEM / path | the system store | Your own root certificates instead of the store |
certificate_public_key_sha256 | list of base64 | — | Public key pinning; incompatible with certificate* |
certificate_sha256 | list of hex | — | SHA-256 of the server's certificate (the leaf or an issuer in the chain), Xray pinnedPeerCertSha256 |
verify_names | list | — | Names the certificate may be issued for, instead of sni, Xray verifyPeerCertByName |
client | block | — | The client certificate (mTLS) the outbound presents to the server: certificate or certificate_path and key or key_path |
utls | block | — | A browser ClientHello fingerprint, see below |
fragment | block | — | ClientHello fragmentation, see below |
ktls | block | — | tx, rx: hand send/receive encryption to the kernel (kTLS, unstable), see below |
handshake_timeout | duration | 15s | The handshake time limit |
engine | string | omitted | Accepted only for sing-box compatibility: go or empty; apple, windows are an error |
reality | block | — | REALITY |
verify_names and certificate_sha256 are extensions from Xray; sing-box does not have them.
By default, like Go in sing-box, the client offers the post-quantum hybrid group X25519MLKEM768 and an X25519 key along with it, so a server without the hybrid picks X25519 without an extra handshake round trip; the server prefers X25519MLKEM768. An explicit curve_preferences sets both the set and the order. curve_preferences does not affect uTLS: the fingerprint sets the groups.
utls
yaml
tls:
sni: example.com
utls:
fingerprint: chromefingerprint: chrome (the default; chrome_psk, chrome_pq and the other chrome variants give the same fingerprint), firefox, edge, safari, ios, qq, random (one of the modern browsers, chosen once per process), randomized (Chrome 133 or Chrome 131, chosen once per process). chrome, firefox and randomized offer X25519MLKEM768, which the REALITY server in Xray requires. firefox is Firefox 148, as in Xray (in sing-box it is Firefox 120 without the post-quantum group), with zlib, brotli and zstd certificate compression. 360 and android offer only TLS 1.2 and are rejected. With utls the client speaks only TLS 1.3: a max_version below 1.3 is an error.
Known limitations of the fingerprint
fingerprint repeats the browser's ClientHello byte for byte, but does not make the connection indistinguishable from a browser: after the ClientHello the behavior is ours, not the browser's.
- TLS 1.3 only. If the server picks 1.2, the client answers with a
protocol_versionalert. - No session resumption: every connection is a full handshake.
chrome_pskand the otherpskvariants are aliases ofchrome. - The browser versions are Chrome 133, Edge 85, Safari 16.0, iOS 14, QQ 11.1 and Firefox 148; most of them are already rare in traffic.
- The
wsandhttpupgradetransports underutlssend theUser-Agentof the same browser and version; the other request headers and their order are not a browser's. AUser-Agentinheaderstakes precedence; withoututlsit isGo-http-client/1.1. randomizedpicks Chrome 133 or 131 once per process. The extension order and random values change on every connection, as with Chrome.
ClientHello fragmentation
yaml
tls:
sni: example.com
fragment:
packet: true
record: true
fallback_delay: 500mspacket splits the first ClientHello at a random point inside the SNI into two socket writes with a fallback_delay pause between them (500ms by default; TCP_NODELAY for the duration of the handshake). record moves the same ClientHello into two valid TLS records. Together they give two TLS records sent separately. The rest of the traffic does not change. Over QUIC (hysteria*, tuic) fragmentation is an error.
kTLS (unstable)
kTLS is unstable and not part of the regular build: it is built only with cargo build -p ours --release --features unstable-ktls. Without it ktls in the config is a load error; with it, a warning at startup. kTLS is rarely faster; only splice forwarding (direct TCP, VLESS without a transport) can benefit.
ktls: {tx: true, rx: true} hands encryption to the Linux kernel after the handshake (the tls module is needed). kTLS requires TLS 1.3; with a TLS 1.2 handshake the connection ends with an error. Over QUIC it is an error.
Inbound (server)
| Field | Type | Default | Meaning |
|---|---|---|---|
certificate, certificate_path | PEM / path | required (without REALITY) | The certificate chain; the file is reread when it changes |
key, key_path | PEM / path | required (without REALITY) | The private key |
insecure | bool | false | Without certificate and key, serve a self-signed certificate (for tests) |
sni | string | — | The server name; for REALITY, the name that is accepted |
alpn | list | from the transport | The server's ALPN |
min_version, max_version, cipher_suites, curve_preferences | As for the client | ||
client_auth | block | — | Verification of client certificates, see below |
ktls | block | — | kTLS, as for the client |
handshake_timeout | duration | 15s | The handshake time limit |
reality | block | — | REALITY |
Built-in answer to a foreign client
A public trojan, vless or anytls server is best hidden behind REALITY or fallbacks to a real web server: then an active probe sees a live site. The built-in answer is a fallback for when there is neither. A TLS client that is not a client of the inbound gets the answer of an empty Caddy 2 site (200 OK, Server: Caddy; 400 to non-HTTP).
The inbound may wait for a request no longer than listener.first_request (60 s by default, as Caddy). A transport stream (ws, grpc, http and so on) in which the protocol itself refused is closed in the transport's normal way: WebSocket close, END_STREAM. An inbound with TLS on a non-loopback address without fallbacks and REALITY writes a warning at startup. The exact answers and how they differ from a real Caddy are in the differences.
client_auth
| Field | Type | Default | Meaning |
|---|---|---|---|
mode | string | no | no, request, require-any, verify-if-given, require-and-verify |
certificate, certificate_path | PEM / list of paths | — | Roots for verifying client certificates |
public_key_sha256 | list of base64 | — | Pinning of client keys |
The sing-box names (kernel_tx, record_fragment, client_key_path, client_authentication, …) are an error with a hint: tls: `kernel_tx` is `ktls.tx` .
Not supported
ech(Encrypted Client Hello) — the schema accepts the field, but neither the client nor the server starts with it:tls.ech: not implemented yet.spoof: {sni, method}—tls.spoof: not implemented yet.
Example: client
yaml
outbounds:
proxy:
trojan:
server: proxy.example.com:443
password: secret
tls:
sni: proxy.example.com
alpn: [h2, http/1.1]
utls:
fingerprint: firefox
fragment:
packet: true
route:
final:
outbound: proxyExample: server that verifies clients
yaml
inbounds:
trojan-in:
trojan:
listen: ":443"
users:
- name: alice
password: secret
tls:
certificate_path: /etc/ours/cert.pem
key_path: /etc/ours/key.pem
min_version: "1.3"
client_auth:
mode: require-and-verify
certificate_path: [/etc/ours/ca.pem]
outbounds:
direct:
direct:
route:
final:
outbound: directFor developers: the tls module.