tlsutil

package
v0.0.0-...-7ea1660 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrsToURLs

func AddrsToURLs(addrs []string, tlsCfg *tls.Config) []string

AddrsToURLs converts a list of addresses to a list of URLs.

func ModifyURLScheme

func ModifyURLScheme(url string, tlsCfg *tls.Config) string

ModifyURLScheme modifies the scheme of the URL based on the TLS config.

func NewCert

func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error)

NewCert generates TLS cert by using the given cert,key and parse function.

func NewCertPool

func NewCertPool(caFiles []string) (*x509.CertPool, error)

NewCertPool creates x509 certPool with provided CA files.

func PickMatchedURL

func PickMatchedURL(urls []string, tlsCfg *tls.Config) string

PickMatchedURL picks the matched URL based on the TLS config. Note: please make sure the URLs are valid.

func TrimHTTPPrefix

func TrimHTTPPrefix(str string) string

TrimHTTPPrefix trims the HTTP/HTTPS prefix from the string.

Types

type TLSConfig

type TLSConfig struct {
	// CAPath is the path of file that contains list of trusted SSL CAs. if set, following four settings shouldn't be empty
	CAPath string `toml:"cacert-path" json:"cacert-path"`
	// CertPath is the path of file that contains X509 certificate in PEM format.
	CertPath string `toml:"cert-path" json:"cert-path"`
	// KeyPath is the path of file that contains X509 key in PEM format.
	KeyPath string `toml:"key-path" json:"key-path"`
	// CertAllowedCNs is the list of CN which must be provided by a client
	CertAllowedCNs []string `toml:"cert-allowed-cn" json:"cert-allowed-cn"`

	SSLCABytes   []byte
	SSLCertBytes []byte
	SSLKEYBytes  []byte
}

TLSConfig is the configuration for supporting tls.

func (TLSConfig) ToTLSConfig

func (s TLSConfig) ToTLSConfig() (*tls.Config, error)

ToTLSConfig generates tls config.

Jump to

Keyboard shortcuts

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