tlsbootstrap

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tlsbootstrap provisions gRPC TLS materials when grpc.tls_enabled is explicitly true. tlsbootstrap 包在 grpc.tls_enabled 显式为 true 时准备 gRPC TLS 证书材料。

Index

Constants

View Source
const (
	// DefaultCertDirName is the default cert subdirectory under storage base dir.
	// DefaultCertDirName 是存储根目录下默认的证书子目录名。
	DefaultCertDirName = "certs"
)

Variables

This section is empty.

Functions

func AgentCAPath

func AgentCAPath() string

AgentCAPath returns the CA certificate path Agents should download when TLS is on. AgentCAPath 返回 Agent 在 TLS 开启时应下载的 CA 证书路径。

Types

type Options

type Options struct {
	// CertDir overrides the certificate directory.
	// CertDir 覆盖证书目录。
	CertDir string

	// ExtraHosts are additional DNS/IP names embedded into the server certificate SAN.
	// ExtraHosts 是写入服务端证书 SAN 的额外 DNS/IP。
	ExtraHosts []string

	// LookPath locates the openssl binary; defaults to exec.LookPath.
	// LookPath 用于查找 openssl;默认使用 exec.LookPath。
	LookPath func(file string) (string, error)

	// CommandRunner runs openssl commands; defaults to exec.Command.
	// CommandRunner 用于执行 openssl;默认使用 exec.Command。
	CommandRunner func(name string, arg ...string) *exec.Cmd
}

Options customizes bootstrap behavior (mainly for tests). Options 自定义引导行为(主要用于测试)。

type Result

type Result struct {
	// TLSEnabled indicates whether gRPC TLS should be enabled after bootstrap.
	// TLSEnabled 表示引导后是否应启用 gRPC TLS。
	TLSEnabled bool

	// CertFile is the server certificate path.
	// CertFile 是服务端证书路径。
	CertFile string

	// KeyFile is the server private key path.
	// KeyFile 是服务端私钥路径。
	KeyFile string

	// CAFile is the CA certificate path for Agent distribution (not mTLS client auth).
	// CAFile 是下发给 Agent 的 CA 证书路径(不是 mTLS 客户端校验用的 ca_file)。
	CAFile string

	// Generated indicates whether new certificates were created in this run.
	// Generated 表示本次是否新生成了证书。
	Generated bool

	// SkippedReason explains why TLS stayed disabled or generation was skipped.
	// SkippedReason 说明为何未开启 TLS 或跳过生成。
	SkippedReason string
}

Result describes the outcome of EnsureGRPCTLS. Result 描述 EnsureGRPCTLS 的结果。

func EnsureGRPCTLS

func EnsureGRPCTLS(opts Options) (Result, error)

EnsureGRPCTLS prepares unidirectional gRPC TLS materials when explicitly enabled. EnsureGRPCTLS 在显式开启时准备单向 gRPC TLS 材料。

Behavior / 行为: - grpc.tls_enabled=false(默认)→ 不生成、不强制开启,即使磁盘上已有证书 - grpc.tls_enabled=true 且证书已存在 → 启用并指向现有文件,不覆盖 - grpc.tls_enabled=true 且证书缺失 → 本机有 openssl 则自动生成;无则保持关闭并打日志

Jump to

Keyboard shortcuts

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