tls

package
v1.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyType = RSAKeyType
View Source
var (
	DefaultValidityPeriod = 10 * 365 * 24 * time.Hour
)

Functions

func ParsePrivateKey added in v1.8.1

func ParsePrivateKey(data []byte) (crypto.PrivateKey, error)

ParsePrivateKey parses an ASN.1 DER-encoded private key. This is basically what tls.X509KeyPair does internally.

func VerifyOnlyCA

func VerifyOnlyCA(caPool *x509.CertPool) func([][]byte, [][]*x509.Certificate) error

Types

type CertType

type CertType string
const (
	ServerCertType CertType = "server"
	ClientCertType CertType = "client"
)

type KeyPair

type KeyPair struct {
	CertPEM []byte
	KeyPEM  []byte
}

func NewSelfSignedCert

func NewSelfSignedCert(commonName string, certType CertType, keyType KeyType, hosts ...string) (KeyPair, error)

func ToKeyPair

func ToKeyPair(key crypto.PrivateKey, cert []byte) (*KeyPair, error)

type KeyType added in v1.8.1

type KeyType func() (crypto.Signer, error)
var ECDSAKeyType KeyType = func() (crypto.Signer, error) {
	return ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
}
var RSAKeyType KeyType = func() (crypto.Signer, error) {
	return util_rsa.GenerateKey(util_rsa.DefaultKeySize)
}

Jump to

Keyboard shortcuts

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