sslutil

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

func EncodePublicKeyPEM(key crypto.PublicKey) ([]byte, error)

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 NewPrivateKey(keytype string) (interface{}, error)

func ParsePrivateKeyPEM

func ParsePrivateKeyPEM(keyData []byte) (interface{}, error)

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 PublicKey

func PublicKey(priv interface{}) interface{}

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

type AltNames struct {
	DNSNames []string `json:"DNSNames"`
	IPs      []net.IP `json:"IPs"`
}

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

func NewCertConfig

func NewCertConfig(validity int, commonname string, organization []string, altnames []string) *CertConf

Jump to

Keyboard shortcuts

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