Documentation ¶
Index ¶
- Constants
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func EncodePrivateKeyPEM(key rsa.PrivateKey) ([]byte, error)
- func EncodePublicKeyPEM(key crypto.PublicKey) ([]byte, error)
- func GetAllSans(crt *x509.Certificate) (sans []string)
- func LoadCrtAndKeyFromPEM(certPEM []byte, keyPEM []byte) (crt *x509.Certificate, key interface{}, err error)
- func MarshalPrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error)
- func NewPrivateKey(keytype string) (interface{}, error)
- func ParsePrivateKeyPEM(keyData []byte) (interface{}, error)
- func PublicKey(priv interface{}) interface{}
- func SelfSignedCaKey(cfg CertConf, caKey interface{}) (*x509.Certificate, interface{}, error)
- func SelfSignedCertKey(cfg CertConf, caCertificate *x509.Certificate, caKey, certKey interface{}) (*x509.Certificate, interface{}, error)
- func VerifyCrtSignature(crt *x509.Certificate, key interface{}) (err error)
- type AltNames
- type CertConf
Constants ¶
const ( // PrivateKeyBlockType is a possible value for pem.Block.Type. PrivateKeyBlockType = "PRIVATE KEY" // PublicKeyBlockType is a possible value for pem.Block.Type. PublicKeyBlockType = "PUBLIC KEY" // CertificateBlockType is a possible value for pem.Block.Type. CertificateBlockType = "CERTIFICATE" // RSAPrivateKeyBlockType is a possible value for pem.Block.Type. RSAPrivateKeyBlockType = "RSA PRIVATE KEY" // ECPrivateKeyBlockType is a possible value for pem.Block.Type. ECPrivateKeyBlockType = "EC PRIVATE KEY" Duration1d = time.Hour * 24 Duration365d = time.Hour * 24 * 365 )
Variables ¶
This section is empty.
Functions ¶
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM returns PEM-endcoded certificate data
func EncodePrivateKeyPEM ¶
func EncodePrivateKeyPEM(key rsa.PrivateKey) ([]byte, error)
EncodePrivateKeyPEM returns PEM-encoded public data
func EncodePublicKeyPEM ¶
EncodePrivateKeyPEM returns PEM-encoded private data
func GetAllSans ¶
func GetAllSans(crt *x509.Certificate) (sans []string)
func LoadCrtAndKeyFromPEM ¶
func LoadCrtAndKeyFromPEM(certPEM []byte, keyPEM []byte) (crt *x509.Certificate, key interface{}, err error)
func MarshalPrivateKeyToPEM ¶
func MarshalPrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error)
MarshalPrivateKeyToPEM converts a known private key type of RSA or ECDSA to a PEM encoded block or returns an error.
func NewPrivateKey ¶
func ParsePrivateKeyPEM ¶
ParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. Recognizes PEM blocks for "EC PRIVATE KEY", "RSA PRIVATE KEY", or "PRIVATE KEY"
func SelfSignedCaKey ¶
func SelfSignedCaKey(cfg CertConf, caKey interface{}) (*x509.Certificate, interface{}, error)
SelfSignedCaKey creates a CA certificate
func SelfSignedCertKey ¶
func SelfSignedCertKey(cfg CertConf, caCertificate *x509.Certificate, caKey, certKey interface{}) (*x509.Certificate, interface{}, error)
func VerifyCrtSignature ¶
func VerifyCrtSignature(crt *x509.Certificate, key interface{}) (err error)
Types ¶
type AltNames ¶
AltNames contains the domain names and IP addresses that will be added to the API Server's x509 certificate SubAltNames field. The values will be passed directly to the x509.Certificate object.
type CertConf ¶
type CertConf struct { // Validity in days Validity int `json:"Validity"` KeySize int `json:"KeySize"` CommonName string `json:"CommonName"` Organization []string `json:"Organization"` OrganizationalUnit []string `json:"OrganizationalUnit"` Country []string `json:"Country"` Locality []string `json:"Locality"` Province []string `json:"Province"` StreetAddress []string `json:"StreetAddress"` PostalCode []string `json:"PostalCode"` AltNames AltNames `json:"AltNames"` Usages []x509.ExtKeyUsage }
CertConf contains the basic fields required for creating a certificate