Skip to content

TLS

顶层 tls 块承载默认 TLS 凭据 —— 由 external-controller-tls 监听器使用,以及那些选择从全局块继承证书而非自带的入站。

选项

字段类型默认值允许值描述
certificatestring(unset)<PEM file path> | <PEM literal>未自带证书的入站使用的默认 TLS 证书。可填文件路径或内联 PEM 块。
private-keystring(unset)<key file path> | <key literal>与 `certificate` 配对的私钥。
client-auth-typestring(none)no-client-cert | request-client-cert | require-any-client-cert | verify-client-cert-if-given | require-and-verify-client-certGo 标准的 ClientAuth 设置,控制访问 TLS 保护入站的客户端是否必须出示证书。
client-auth-certstring(unset)<PEM file path>作为客户端根证书的 PEM 集合。
ech-keystring(unset)<ECH config / key>支持 ECH 的入站使用的 ECH(Encrypted Client Hello)配置 / 密钥。
custom-certifactes[]string[]<PEM file path>添加到信任集中的额外 CA 证书,校验出站对端时使用。(注意源代码拼写为 `certifactes`。)

源码: config/config.go:384-391 · 锚定版本 v1.19.27 (5184081)

示例

yaml
tls:
  certificate: /etc/mihomo/server.crt
  private-key: /etc/mihomo/server.key
  client-auth-type: require-and-verify-client-cert
  client-auth-cert: /etc/mihomo/clients-ca.crt
  custom-certifactes:
    - /etc/mihomo/extra-ca.crt

说明

  • 源代码字段名 custom-certifactes 拼写有误(缺一个 i);此处保留 原拼写以匹配实际 YAML 键。
  • 内联 certificate / private-key 块需要字面换行 —— 进版本控制的 内容建议改用文件路径。

源码: config/config.go:384-391 · v1.19.27 (5184081)

由 Argsment 出品的 Core Tutorial