tls

package
v0.0.0-...-d86545f Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerCertType              CertType = "server"
	ClientCertType              CertType = "client"
	DefaultAllowedClockSkew              = 5 * time.Minute
	DefaultCACertValidityPeriod          = 10 * 365 * 24 * time.Hour
)

Variables

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

Functions

func ParsePrivateKey

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

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

Types

type CertType

type CertType string

type KeyPair

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

func GenerateCA

func GenerateCA(keyType KeyType, subject pkix.Name) (*KeyPair, error)

func NewCert

func NewCert(
	parent x509.Certificate,
	parentKey crypto.Signer,
	certType CertType,
	keyType KeyType,
	hosts ...string,
) (KeyPair, error)

NewCert generates certificate that is signed by the CA (parent)

func NewSelfSignedCert

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

func ToKeyPair

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

type KeyType

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