tls

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert(organization, commonName string, dnsNames []string, ipAddresses []string, validFor time.Duration, outDir string) error

生成自签名证书工具函数 (简化版)

Types

type TLSConfig

type TLSConfig struct {
	// 证书文件路径
	CertFile string
	// 私钥文件路径
	KeyFile string
	// CA证书文件路径
	CAFile string
	// 是否验证客户端证书
	ClientAuth tls.ClientAuthType
	// 服务名
	ServerName string
	// 最小TLS版本
	MinVersion uint16
	// 最大TLS版本
	MaxVersion uint16
	// 是否启用OCSP校验
	EnableOCSP bool
	// 允许的密码套件
	CipherSuites []uint16
	// 证书轮转检查间隔
	RotationInterval time.Duration
	// OCSP检查间隔
	OCSPCheckInterval time.Duration
	// 证书过期前预警时间
	ExpiryWarningPeriod time.Duration
	// contains filtered or unexported fields
}

TLSConfig 是TLS配置的强化版

func DefaultTLSConfig

func DefaultTLSConfig() *TLSConfig

DefaultTLSConfig 返回默认TLS配置

func (*TLSConfig) AutoRotate

func (t *TLSConfig) AutoRotate(certDir string, certPrefix string) error

AutoRotate 配置证书自动轮转

func (*TLSConfig) SetupClientConfig

func (t *TLSConfig) SetupClientConfig() (*tls.Config, error)

SetupClientConfig 设置客户端TLS配置

func (*TLSConfig) SetupServerConfig

func (t *TLSConfig) SetupServerConfig() (*tls.Config, error)

SetupServerConfig 设置服务端TLS配置

func (*TLSConfig) ToGRPCOptions

func (t *TLSConfig) ToGRPCOptions() (credentials.TransportCredentials, error)

ToGRPCOptions 生成gRPC TLS选项

Jump to

Keyboard shortcuts

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