certs

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package certs 处理主控 push_cert 下发的 TLS 证书落盘。

约定(05 号文档 §4):落盘 `/etc/xray/certs/<domain>/{fullchain.pem,key.pem}`, fullchain 0644、key 0600,原子写;xray 默认每小时热重载证书文件,换证不重启。 证书/私钥校验与解析在共享包 pkg/tlscert(主控 certs API 同源)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CAPath added in v0.2.0

func CAPath(dir string, id uint64) string

CAPath CA 根证书的固定落盘路径:<certs_dir>/ca/<id>.crt。 主控按同一约定生成出站配置的 certificateFile(见 contracts.CACertPath)。

func SanitizeDomain

func SanitizeDomain(domain string) string

SanitizeDomain 供日志使用(委托共享包)。

func SyncManaged added in v0.2.0

func SyncManaged(dir string, domains []string) ([]string, error)

SyncManaged 清理 <dir> 下不再被引用的托管证书目录,返回被删除的域名列表。

只处理同时满足以下条件的子目录,避免误删人工放置的东西:

  • 目录名是合法域名(DomainRe);
  • 不是 ca/(CA 公钥由 push_ca 管理,另有生命周期);
  • 目录内存在 fullchain.pem(即 push_cert 写出的布局)。

domains 是主控当前仍引用的域名全集;缺省/空集合表示"没有任何证书被引用", 此时会清掉全部托管目录(解绑/删除后的正常 GC 行为)。

func ValidatePair

func ValidatePair(certPEM, keyPEM string) error

ValidatePair 校验证书与私钥(委托共享包)。

func Write

func Write(dir, domain, certPEM, keyPEM string) error

Write 校验并落盘 <dir>/<domain>/{fullchain.pem,key.pem}(原子写;key 600)。

func WriteCA added in v0.2.0

func WriteCA(dir string, id uint64, certPEM string) (string, error)

WriteCA 校验并落盘 CA 根证书(只有公钥;CA 私钥永不下发)。 返回落盘路径供回执/日志使用。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL