ca

package
v1.19.32-clash.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	NoClientCert               = tls.NoClientCert
	RequestClientCert          = tls.RequestClientCert
	RequireAnyClientCert       = tls.RequireAnyClientCert
	VerifyClientCertIfGiven    = tls.VerifyClientCertIfGiven
	RequireAndVerifyClientCert = tls.RequireAndVerifyClientCert
)

Variables

View Source
var DisableEmbedCa, _ = strconv.ParseBool(os.Getenv("DISABLE_EMBED_CA"))
View Source
var DisableSystemCa, _ = strconv.ParseBool(os.Getenv("DISABLE_SYSTEM_CA"))

Functions

func AddCertificate

func AddCertificate(certificate string) error

func CalculateFingerprint

func CalculateFingerprint(certDER []byte) string

CalculateFingerprint computes the SHA-256 fingerprint of the given DER-encoded certificate and returns it as a hex string.

func ClientAuthTypeToString

func ClientAuthTypeToString(t ClientAuthType) string

func GetCertPool

func GetCertPool() *x509.CertPool

func GetTLSConfig

func GetTLSConfig(opt Option) (tlsConfig *tls.Config, err error)

func LoadCertificates

func LoadCertificates(certificate string) (*x509.CertPool, error)

func NewFingerprintVerifier

func NewFingerprintVerifier(fingerprint string, time func() time.Time) (func(certs []*x509.Certificate, serverName string) error, error)

NewFingerprintVerifier returns a function that verifies whether a certificate's SHA-256 fingerprint matches the given one.

func NewNameCertVerifier

func NewNameCertVerifier(dnsName string, roots *x509.CertPool, now func() time.Time) func([]*x509.Certificate) error

NewNameCertVerifier returns a verifier for a certificate chain and an explicit DNSName.

func NewRandomTLSKeyPair

func NewRandomTLSKeyPair(keyPairType KeyPairType) (certificate string, privateKey string, fingerprint string, err error)

NewRandomTLSKeyPair generates a random TLS key pair based on the specified KeyPairType and returns it with a SHA256 fingerprint. Note: Most browsers do not support KeyPairTypeEd25519 type of certificate, and utls.UConn will also reject this type of certificate.

func NewTLSKeyPairLoader

func NewTLSKeyPairLoader(certificate, privateKey string) (func() (*tls.Certificate, error), error)

NewTLSKeyPairLoader creates a loader function for TLS key pairs from the provided certificate and private key data or file paths. If both certificate and privateKey are empty, generates a random TLS RSA key pair.

func ResetCertificate

func ResetCertificate()

func SetStore

func SetStore(store Store)

Types

type ClientAuthType

type ClientAuthType = tls.ClientAuthType

func ClientAuthTypeFromString

func ClientAuthTypeFromString(s string) ClientAuthType

type KeyPairType

type KeyPairType string
const (
	KeyPairTypeRSA     KeyPairType = "rsa"
	KeyPairTypeP256    KeyPairType = "p256"
	KeyPairTypeP384    KeyPairType = "p384"
	KeyPairTypeEd25519 KeyPairType = "ed25519"
)

type Option

type Option struct {
	TLSConfig      *tls.Config
	Fingerprint    string
	NameCertVerify string
	ZeroTrust      bool
	Certificate    string
	PrivateKey     string
}

type Store

type Store string
const (
	StoreDefault Store = ""
	StoreSystem  Store = "system"
	StoreMozilla Store = "mozilla"
	StoreChrome  Store = "chrome"
	StoreNone    Store = "none"
)

func ParseStore

func ParseStore(value string) (Store, error)

func SelectedStore

func SelectedStore() Store

Jump to

Keyboard shortcuts

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