tlsutil

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

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

func GetClientTLSConfig(opts ...SSLConfigOption) (tlsConfig *tls.Config, err error)

*

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

func GetServerTLSConfig

func GetServerTLSConfig(opts ...SSLConfigOption) (tlsConfig *tls.Config, err error)

func GetX509CACertPool

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

func LoadTLSCertificate

func LoadTLSCertificate(certFile, keyFile, plainPassphase string) (tlsCert []tls.Certificate, err error)

func ParseDefaultSSLCipherSuites

func ParseDefaultSSLCipherSuites(ciphers string) []uint16

func ParseSSLCipherSuites

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

func ParseSSLProtocol

func ParseSSLProtocol(sprotocol string) uint16

func TLSCipherSuits

func TLSCipherSuits() []uint16

Types

type SSLConfig

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

type SSLConfigOption

type SSLConfigOption func(*SSLConfig)

func DefaultClientTLSOptions

func DefaultClientTLSOptions() []SSLConfigOption

func DefaultServerTLSOptions

func DefaultServerTLSOptions() []SSLConfigOption

func WithCA

func WithCA(f string) SSLConfigOption

func WithCert

func WithCert(f string) SSLConfigOption

func WithCipherSuits

func WithCipherSuits(s []uint16) SSLConfigOption

func WithKey

func WithKey(k string) SSLConfigOption

func WithKeyPass

func WithKeyPass(p string) SSLConfigOption

func WithVerifyHostName

func WithVerifyHostName(b bool) SSLConfigOption

func WithVerifyPeer

func WithVerifyPeer(b bool) SSLConfigOption

func WithVersion

func WithVersion(min, max uint16) SSLConfigOption

Jump to

Keyboard shortcuts

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