tlsutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxSupportedTLSVersion uint16 = tls.VersionTLS12

MaxSupportedTLSVersion is the max supported TLS version

View Source
var TLSCipherSuiteMap = map[string]uint16{
	"TLS_RSA_WITH_AES_128_GCM_SHA256":       tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
	"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
	"TLS_RSA_WITH_AES_256_GCM_SHA384":       tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
	"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
	"TLS_RSA_WITH_AES_128_CBC_SHA256":       tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
}
View Source
var TLSVersionMap = map[string]uint16{
	"TLSv1.0": tls.VersionTLS10,
	"TLSv1.1": tls.VersionTLS11,
	"TLSv1.2": tls.VersionTLS12,
}

Functions

func GetClientTLSConfig added in v0.4.0

func GetClientTLSConfig(ops ...TLSOption) (tlsConfig *tls.Config, err error)

GetClientTLSConfig

verifyPeer    Whether verify client
supplyCert    Whether send certificate
verifyCN      Whether verify CommonName

func GetServerTLSConfig added in v0.4.0

func GetServerTLSConfig(ops ...TLSOption) (tlsConfig *tls.Config, err error)

func GetX509CACertPool

func GetX509CACertPool(caCertFile string) (*x509.CertPool, error)

GetX509CACertPool is a function used to get certificate

func LoadTLSCertificate

func LoadTLSCertificate(certFile, keyFile, password string, decrypt Decrypt) ([]tls.Certificate, error)

LoadTLSCertificate is a function used to load a certificate RFC 1423 is insecure, password and decrypt is not required

func ParseDefaultSSLCipherSuites added in v0.4.0

func ParseDefaultSSLCipherSuites(ciphers string) []uint16

func ParseSSLCipherSuites added in v0.4.0

func ParseSSLCipherSuites(ciphers string, permitTLSCipherSuiteMap map[string]uint16) []uint16

func ParseSSLProtocol added in v0.4.0

func ParseSSLProtocol(sprotocol string) uint16

func TLSCipherSuits added in v0.4.0

func TLSCipherSuits() []uint16

Types

type Decrypt added in v0.2.2

type Decrypt func(src string) (string, error)

type TLSOption added in v0.4.0

type TLSOption func(*TLSOptions)

func DefaultClientTLSOptions added in v0.4.0

func DefaultClientTLSOptions() []TLSOption

func DefaultServerTLSOptions added in v0.4.0

func DefaultServerTLSOptions() []TLSOption

func WithCA added in v0.4.0

func WithCA(f string) TLSOption

func WithCert added in v0.4.0

func WithCert(f string) TLSOption

func WithCipherSuits added in v0.4.0

func WithCipherSuits(s []uint16) TLSOption

func WithDecrypt added in v0.4.0

func WithDecrypt(f Decrypt) TLSOption

func WithKey added in v0.4.0

func WithKey(k string) TLSOption

func WithKeyPass added in v0.4.0

func WithKeyPass(p string) TLSOption

func WithVerifyHostName added in v0.4.0

func WithVerifyHostName(b bool) TLSOption

func WithVerifyPeer added in v0.4.0

func WithVerifyPeer(b bool) TLSOption

func WithVersion added in v0.4.0

func WithVersion(min, max uint16) TLSOption

type TLSOptions added in v0.4.0

type TLSOptions struct {
	VerifyPeer     bool
	VerifyHostName bool
	CipherSuites   []uint16
	MinVersion     uint16
	MaxVersion     uint16
	CACertFile     string
	CertFile       string
	KeyFile        string
	KeyPassphase   string
	Decrypt        Decrypt
}

Jump to

Keyboard shortcuts

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