证书
certificate 块选择 sing-box 在校验 TLS 服务端证书时使用的信任集。 先挑一个基础 store,再可选地以字符串、文件或目录形式扩展。
选项
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
store | string | system | system | mozilla | chrome | none | 用作信任基础的根 CA 集合。`system` 读取操作系统根证书;`mozilla` 与 `chrome` 使用内置快照;`none` 以空信任集起步。 |
certificate | badoption.Listable[string] | [] | <PEM block> | 在基础信任集之上追加的内联 PEM 证书列表。 |
certificate_path | badoption.Listable[string] | [] | <file path> | 在基础信任集之上追加的 PEM 文件路径列表。 |
certificate_directory_path | badoption.Listable[string] | [] | <dir path> | 目录列表;其中的 .pem / .crt / .cer 文件都会被追加到基础信任集。 |
源码: option/certificate.go:9-14 · 锚定版本 v1.13.11 (553cfa1)
示例
json
{
"certificate": {
"store": "mozilla",
"certificate_path": ["/etc/ssl/extra/my-corp-root.pem"]
}
}说明
- 缺失或为空的
store会被归一化为system(option/certificate.go:31-33)。 - 三个「附加」字段都是 累加 的 —— 在基础 store 之上合并,而非 替换。如果要严格的精挑信任集,请选
store: "none"并显式列出每张 证书。 - 自签名场景适合用内联 inline 证书;多数生产场景下推荐指向目录或 文件路径,便于在不改动配置的情况下轮换信任集。
源码: option/certificate.go:9-14 · v1.13.11 (553cfa1)
