cert

package
v0.0.0-...-41e0b01 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 18 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 GetClientCA

func GetClientCA(client kubernetes.Interface) (clientCA []byte, err error)

func IsPopulated

func IsPopulated(secret *corev1.Secret) bool

IsPopulated returns true if the given Secret object contains the serving key and 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 Bundle

type Bundle struct {
	Serving
	ServingCertCA []byte
}

Bundle encapsulates - PEM encoded serving private key and certificate - certificate of the self-signed CA that signed the serving cert.

func GenerateWithLocalhostServing

func GenerateWithLocalhostServing(notAfter time.Time, organization string) (bundle *Bundle, err error)

GenerateWithLocalhostServing generates self-signed 'localhost' serving cert(s).

func (*Bundle) Hash

func (b *Bundle) Hash() string

Hash generates a sha256 hash of the given Bundle object The hash is generated from the hash of the serving key, serving cert, serving CA cert.

func (*Bundle) Validate

func (b *Bundle) Validate() 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 Serving

type Serving struct {
	ServiceKey  []byte
	ServiceCert []byte
}

Jump to

Keyboard shortcuts

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