crypto

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKeyPair

func NewKeyPair() (crypto.PublicKey, crypto.PrivateKey, error)

Types

type CA

type CA struct {
	Dir        string
	SerialFile string
	Serial     int64
	Config     *TLSCertificateConfig
}

func InitCA

func InitCA(dir string, name string) (*CA, error)

InitCA ensures a certificate authority structure exists in the given directory, creating it if necessary:

<dir>/
  ca/
root.crt	- Root certificate bundle.
cert.crt	- Signing certificate
key.key	 - Private key
serial.txt  - Stores the highest serial number generated by this CA

func (*CA) MakeClientConfig

func (ca *CA) MakeClientConfig(username string, defaults kclient.Config) (kclient.Config, error)

MakeClientConfig creates a folder containing certificates for the given client:

<CA.dir>/
 <username>/
root.crt	- Root certificate bundle.
cert.crt	- Client certificate
key.key	 - Private key

The generated certificate has the following attributes:

CommonName: username
ExtKeyUsage: ExtKeyUsageClientAuth

func (*CA) MakeServerCert

func (ca *CA) MakeServerCert(name string, hostnames []string) (*TLSCertificateConfig, error)

MakeServerCert creates a folder containing certificates for the given server:

<CA.dir>/
 <name>/
root.crt	- Root certificate bundle.
cert.crt	- Server certificate
key.key	 - Private key

The generated certificate has the following attributes:

CommonName: hostnames[0]
DNSNames subjectAltNames containing all specified hostnames
IPAddresses subjectAltNames containing all specified hostnames which are IP addresses
ExtKeyUsage: ExtKeyUsageServerAuth

type TLSCertificateConfig

type TLSCertificateConfig struct {
	CAFile   string
	CertFile string
	KeyFile  string

	Roots []*x509.Certificate
	Certs []*x509.Certificate
	Key   crypto.PrivateKey
}

Jump to

Keyboard shortcuts

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