testcerts

package
v0.0.0-...-32caa19 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCertTempl = x509.Certificate{
	SerialNumber:          big.NewInt(1),
	KeyUsage:              x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
	ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
	BasicConstraintsValid: true,
	NotBefore:             time.Now().Add(-1 * time.Hour),
	NotAfter:              time.Now().Add(1 * time.Hour),
}
View Source
var ExpiredCertTempl = x509.Certificate{
	SerialNumber:          big.NewInt(1),
	KeyUsage:              x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
	ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
	BasicConstraintsValid: true,
	NotBefore:             time.Now().Add(-2 * time.Hour),
	NotAfter:              time.Now().Add(-1 * time.Hour),
}
View Source
var NotYetValidCertTempl = x509.Certificate{
	SerialNumber:          big.NewInt(1),
	KeyUsage:              x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
	ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
	BasicConstraintsValid: true,
	NotBefore:             time.Now().Add(1 * time.Hour),
	NotAfter:              time.Now().Add(2 * time.Hour),
}

Functions

func CreateSelfSignedCert

func CreateSelfSignedCert(t *testing.T, keyType string, template x509.Certificate) (certBytes []byte, keyBytes []byte)

CreateSelfSignedCert is a test helper that creates a self-signed certificate from a template and returns the PEM encoded certificate and key.

func GeneratePrivateKey

func GeneratePrivateKey(t *testing.T, keyType string) crypto.PrivateKey

func WritePrivateKey

func WritePrivateKey(t *testing.T, keyType string, path string) crypto.PrivateKey

func WriteRSAPublicKey

func WriteRSAPublicKey(t *testing.T, path string)

func WriteSelfSignedCert

func WriteSelfSignedCert(t *testing.T, keyType string, basePath string, templ x509.Certificate)

WriteSelfSignedCert is a test helper to write a self-signed certificate, as defined by templ, and its corresponding key in PEM formats to files suffixed by ".crt" and ".key" respectively to the path specified by basePath.

Types

This section is empty.

Jump to

Keyboard shortcuts

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