certificate

package
v1.4.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientCert = "cert.pem"
	ClientKey  = "key.pem"
	ServerCert = "server-cert.pem"
	ServerKey  = "server-key.pem"
	CACert     = "ca.pem"
	CAKey      = "ca-key.pem"
)

Default certificate file names

Variables

This section is empty.

Functions

func CreateClientCertificate

func CreateClientCertificate(domain string, org []string, size int, cb, kb []byte) (cert bytes.Buffer, key bytes.Buffer, err error)

func CreateRootCA

func CreateRootCA(domain string, org []string, size int) (cert bytes.Buffer, key bytes.Buffer, err error)

func CreateSelfSigned

func CreateSelfSigned(domain string, org []string, size int) (cert bytes.Buffer, key bytes.Buffer, err error)

func CreateServerCertificate

func CreateServerCertificate(domain string, org []string, size int, cb, kb []byte) (cert bytes.Buffer, key bytes.Buffer, err error)

func ParseCertificate

func ParseCertificate(cb, kb []byte) (*x509.Certificate, *rsa.PrivateKey, error)

func VerifyClientCert

func VerifyClientCert(ca []byte, ckp *KeyPair) (*tls.Certificate, error)

VerifyClientCert verifies the loaded client cert keypair against the input CA and returns the certificate on success.

Types

type CertParseError

type CertParseError struct {
	// contains filtered or unexported fields
}

CertParseError is returned when there's an error parsing a cert.

func (CertParseError) Error

func (e CertParseError) Error() string

type CertVerifyError

type CertVerifyError struct{}

CertVerifyError is returned when the client cert cannot be validated against the CA.

func (CertVerifyError) Error

func (e CertVerifyError) Error() string

type CreateCAPoolError

type CreateCAPoolError struct{}

CreateCAPoolError is returned when there's an error creating a CA cert pool.

func (CreateCAPoolError) Error

func (e CreateCAPoolError) Error() string

type KeyPair

type KeyPair struct {
	KeyPEM  []byte
	CertPEM []byte

	KeyFile  string
	CertFile string
}

func NewKeyPair

func NewKeyPair(certFile, keyFile string, certPEM, keyPEM []byte) *KeyPair

func (*KeyPair) Certificate

func (kp *KeyPair) Certificate() (*tls.Certificate, error)

Certificate turns the KeyPair back into useful TLS constructs This attempts to populate the certificate.Leaf field with the x509 certificate for convenience

func (*KeyPair) CreateClientCertificate

func (kp *KeyPair) CreateClientCertificate(domain string, org []string, size int, ca *KeyPair) error

func (*KeyPair) CreateRootCA

func (kp *KeyPair) CreateRootCA(domain string, org []string, size int) error

func (*KeyPair) CreateSelfSigned

func (kp *KeyPair) CreateSelfSigned(domain string, org []string, size int) error

func (*KeyPair) CreateServerCertificate

func (kp *KeyPair) CreateServerCertificate(domain string, org []string, size int, ca *KeyPair) error

func (*KeyPair) LoadCertificate

func (kp *KeyPair) LoadCertificate() error

func (*KeyPair) SaveCertificate

func (kp *KeyPair) SaveCertificate() error

Jump to

Keyboard shortcuts

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