certs

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active(cert *x509.Certificate) bool

Active checks if the given cert is within its valid time window

func PEMSHA256

func PEMSHA256(certPEM []byte) (hash string)

PEMSHA256 returns the hex encoded SHA 256 hash of the given PEM encoded cert

func PEMToCert

func PEMToCert(certPEM []byte) (*x509.Certificate, error)

PEMToCert converts the PEM block of the given byte array to an x509 certificate

func VerifyCert

func VerifyCert(ca, cert *x509.Certificate, host string) error

VerifyCert checks that the given cert is signed and trusted by the given CA

Types

type CertGenerator added in v0.18.0

type CertGenerator interface {
	Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
}

type CertGeneratorFunc added in v0.18.0

type CertGeneratorFunc func(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)

func (CertGeneratorFunc) Generate added in v0.18.0

func (f CertGeneratorFunc) Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)

type KeyPair

type KeyPair struct {
	Cert *x509.Certificate
	Priv *ecdsa.PrivateKey
}

KeyPair stores an x509 certificate and its ECDSA private key

func CreateSignedServingPair

func CreateSignedServingPair(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)

CreateSignedServingPair creates a serving cert/key pair signed by the given ca

func GenerateCA

func GenerateCA(notAfter time.Time, organization string) (*KeyPair, error)

GenerateCA generates a self-signed CA cert/key pair that expires in expiresIn days

func (*KeyPair) ToPEM

func (kp *KeyPair) ToPEM() (certPEM []byte, privPEM []byte, err error)

ToPEM returns the PEM encoded cert pair

type PEMHash

type PEMHash func(certPEM []byte) (hash string)

PEMHash returns a hash of the given PEM encoded cert

Jump to

Keyboard shortcuts

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