Skip to content

证书 ​

certificate 块选择 sing-box 在校验 TLS 服务端证书时使用的信任集。先挑一个基础 store,再可选地以字符串、文件或目录形式扩展。

选项 ​

字段类型默认值允许值描述
storestringsystemsystem | mozilla | chrome | none用作信任基础的根 CA 集合。system 读取操作系统根证书;mozilla 与 chrome 使用内置快照;none 以空信任集起步。
certificatebadoption.Listable[string][]<PEM block>在基础信任集之上追加的内联 PEM 证书列表。
certificate_pathbadoption.Listable[string][]<file path>在基础信任集之上追加的 PEM 文件路径列表。
certificate_directory_pathbadoption.Listable[string][]<dir path>目录列表;其中的 .pem / .crt / .cer 文件都会被追加到基础信任集。

源码: option/certificate.go:12-17 · 锚定版本 v1.14.2 (af6e64c)

示例 ​

json
{
  "certificate": {
    "store": "mozilla",
    "certificate_path": ["/etc/ssl/extra/my-corp-root.pem"]
  }
}

说明 ​

  • 缺失或为空的 store 会被归一化为 system(option/certificate.go:34-36)。
  • 三个「附加」字段都是 累加 的 —— 在基础 store 之上合并,而非替换。如果要严格的精挑信任集,请选 store: "none" 并显式列出每张证书。
  • 自签名场景适合用内联 inline 证书;多数生产场景下推荐指向目录或文件路径,便于在不改动配置的情况下轮换信任集。

源码: option/certificate.go:12-17 · v1.14.2 (af6e64c)

由 Argsment 出品的 Core Tutorial