Documentation ¶
Overview ¶
Package util provides generic utility functions.
Index ¶
- Variables
- func DecodeCertificate(certPEM []byte) (*x509.Certificate, error)
- func DecodePrivateKey(keyPEM []byte) (crypto.PrivateKey, error)
- func GenerateCertificate(keyPEM []byte, cn string, lifetime time.Duration, usage CertificateUsage, ...) ([]byte, error)
- func GenerateKey(keyType KeyType, encoding KeyEncodingType, bits *int) ([]byte, error)
- func MustWaitFor(t *testing.T, f WaitFunc, timeout time.Duration)
- func WaitFor(f WaitFunc, timeout time.Duration) error
- type CertificateUsage
- type KeyEncodingType
- type KeyType
- type WaitFunc
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPublicKey = goerrors.New("invalid public key")
ErrInvalidPublicKey is raised when the public key type is unknown/unsupported.
var ErrInvalidSubjectAltName = goerrors.New("invalid subject alt name")
ErrInvalidSubjectAltName is raised when an unsupported SAN is specified.
var ErrTimeout = errors.New("process timed out")
ErrTimeout is raised when a wait doesn't terminate in time.
Functions ¶
func DecodeCertificate ¶
func DecodeCertificate(certPEM []byte) (*x509.Certificate, error)
DecodeCertificate accepts an parses a PEM formatted certificate.
func DecodePrivateKey ¶
func DecodePrivateKey(keyPEM []byte) (crypto.PrivateKey, error)
DecodePrivateKey accepts a PEM formatted private key and parses it.
func GenerateCertificate ¶
func GenerateCertificate(keyPEM []byte, cn string, lifetime time.Duration, usage CertificateUsage, sans []string, caKeyPEM, caCertPEM []byte) ([]byte, error)
GenerateCertificate generates and signs an X.509 certificate.
func GenerateKey ¶
func GenerateKey(keyType KeyType, encoding KeyEncodingType, bits *int) ([]byte, error)
GenerateKey creates a PEM encoded private key. The bits parameter is required for RSA keys.
func MustWaitFor ¶
MustWaitFor waits until a condition is nil.
Types ¶
type CertificateUsage ¶
type CertificateUsage string
CertificateUsage defines the certificate use.
const ( // CA is used for signing certificates and providing a trust anchor. CA CertificateUsage = "CA" // Server is used for server certificates. Server CertificateUsage = "Server" // Client is used for client certificates. Client CertificateUsage = "Client" )
type KeyEncodingType ¶
type KeyEncodingType string
KeyEncodingType is a private key encoding type.
const ( // KeyEncodingPKCS1 may only be used with the RSA key type. KeyEncodingPKCS1 KeyEncodingType = "PKCS#1" // KeyEncodingPKCS8 may be used for any key type. KeyEncodingPKCS8 KeyEncodingType = "PKCS#8" // KeyEncodingSEC1 may only be used with EC key types. KeyEncodingSEC1 KeyEncodingType = "SEC 1" )
type KeyType ¶
type KeyType string
KeyType is a private key type.
const ( // RSA is widely supported, but the key sizes are large. KeyTypeRSA KeyType = "RSA" // KeyTypeEllipticP224 generates small keys relative to encryption strength. KeyTypeEllipticP224 KeyType = "EllipticP224" // KeyTypeEllipticP256 generates small keys relative to encryption strength. KeyTypeEllipticP256 KeyType = "EllipticP256" // KeyTypeEllipticP384 generates small keys relative to encryption strength. KeyTypeEllipticP384 KeyType = "EllipticP384" // KeyTypeEllipticP521 generates small keys relative to encryption strength. KeyTypeEllipticP521 KeyType = "EllipticP521" // KeyTypeED25519 generates small keys relative to encrption strength. KeyTypeED25519 KeyType = "ED25519" )