tls

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildClientTLS

func BuildClientTLS(c *tlspb.TLS) (*stdtls.Config, error)

BuildClientTLS 从 TLS proto 构造客户端 *tls.Config。 当 c 为 nil 或 enable=false 时返回 (nil, nil),调用方据此决定是否启用 TLS。

func BuildServerTLS

func BuildServerTLS(c *tlspb.TLS) (*stdtls.Config, error)

BuildServerTLS 从 TLS proto 构造服务端 *tls.Config。 当 c 为 nil 或 enable=false 时返回 (nil, nil),调用方据此决定是否启用 TLS。

func LoadCertPoolFromPEMFile

func LoadCertPoolFromPEMFile(path string) (*x509.CertPool, error)

LoadCertPoolFromPEMFile 从 PEM 文件加载证书池。

func MustBuildServerTLS

func MustBuildServerTLS(c *tlspb.TLS) *stdtls.Config

MustBuildServerTLS 是 BuildServerTLS 的 panic 版本,TLS 配置非法时直接 panic。

func MustServerConfig

func MustServerConfig(opts ServerConfigOptions) *stdtls.Config

MustServerConfig 构造服务端 TLS 配置,失败时 panic。

func NewClientConfig

func NewClientConfig(opts ClientConfigOptions) (*stdtls.Config, error)

NewClientConfig 构造客户端 TLS 配置。

func NewServerConfig

func NewServerConfig(opts ServerConfigOptions) (*stdtls.Config, error)

NewServerConfig 构造服务端 TLS 配置。

Types

type ClientConfigOptions

type ClientConfigOptions struct {
	CAPath             string
	CertPath           string
	KeyPath            string
	ServerName         string
	InsecureSkipVerify bool
	MinVersion         uint16
}

ClientConfigOptions 描述客户端 TLS 配置来源。

type ServerConfigOptions

type ServerConfigOptions struct {
	CertPath   string
	KeyPath    string
	MinVersion uint16
}

ServerConfigOptions 描述服务端 TLS 配置来源。

Jump to

Keyboard shortcuts

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