cert

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACME

type ACME struct {
	Enabled  bool     `mapstructure:"enabled" yaml:"enabled"`
	Email    string   `mapstructure:"email" yaml:"email"`
	Domains  []string `mapstructure:"domains" yaml:"domains"`
	CacheDir string   `mapstructure:"cache_dir" yaml:"cache_dir"`
}

ACME (Let's Encrypt) 配置

type Config

type Config struct {
	// 手动证书路径
	CertFile string `mapstructure:"cert_file" yaml:"cert_file"`
	KeyFile  string `mapstructure:"key_file" yaml:"key_file"`

	ACME ACME `mapstructure:"acme" yaml:"acme"`

	// 降级阈值:如果手动证书还有多少天过期,就切换到 ACME (默认 30 天)
	// 如果为 0,表示只有文件不存在或已完全过期才切换
	FallbackThresholdDays int `mapstructure:"fallback_threshold_days" yaml:"fallback_threshold_days"`
}

func DefaultConfig

func DefaultConfig() Config

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager 负责证书的获取、缓存、更新和降级策略。

func New

func New(cfg Config, logger *zerolog.Logger) (*Manager, error)

New 创建证书管理器。

func (*Manager) GetCertificate

func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate 实现 tls.Config.GetCertificate 这是一个高频调用的热点路径,实现了基于 atomic.Pointer 的无锁化读取。

func (*Manager) HTTPHandler

func (m *Manager) HTTPHandler(fallback http.Handler) http.Handler

HTTPHandler ACME 挑战处理器

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start 启动后台监听(Watcher)。

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context) error

Stop 停止管理器

Jump to

Keyboard shortcuts

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