Documentation ¶
Index ¶
- Variables
- func CreateSelfSignedCert(t *testing.T, keyType string, template x509.Certificate) (certBytes []byte, keyBytes []byte)
- func GeneratePrivateKey(t *testing.T, keyType string) crypto.PrivateKey
- func WritePrivateKey(t *testing.T, keyType string, path string) crypto.PrivateKey
- func WriteRSAPublicKey(t *testing.T, path string)
- func WriteSelfSignedCert(t *testing.T, keyType string, basePath string, templ x509.Certificate)
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 WriteRSAPublicKey ¶
func WriteSelfSignedCert ¶
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.
Click to show internal directories.
Click to hide internal directories.