pki

package
v0.0.0-...-2e57681 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2015 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CertificatePreamble = "-----BEGIN CERTIFICATE-----"
View Source
var KeyPreamble = "-----BEGIN RSA PRIVATE KEY-----"

Functions

func GenerateCACertificate

func GenerateCACertificate(certFile, keyFile, org string, bits int) error

GenerateCACertificate generates a new certificate authority from the specified org and bit size and stores the resulting certificate and key file in the arguments.

func GenerateCertificate

func GenerateCertificate(hosts []string, certFile, keyFile, caFile, caKeyFile, org string, bits int) error

GenerateCertificate generates a new certificate signed using the provided certificate authority files and stores the result in the certificate file and key provided. The provided host names are set to the appropriate certificate fields.

func GetCADir

func GetCADir() string

func GetCertDir

func GetCertDir() string

func GetHomeDir

func GetHomeDir() string

func GetPkiDir

func GetPkiDir() string

func GetUsername

func GetUsername() string

func OutputFileContents

func OutputFileContents(file string) (string, error)

func Retryable

func Retryable(f func() error, timeout time.Duration) error

Types

type Config

type Config struct {
	Application    string
	ClientKeyPath  string
	ClientCertPath string
	ServerKeyPath  string
	ServerCertPath string
	CaKeyPath      string
	CaCertPath     string
	Insecure       bool
}

type PKI

type PKI struct {
	Config *Config
}

func New

func New() (*PKI, error)

func NewWithConfig

func NewWithConfig(config *Config) (*PKI, error)

func (*PKI) CheckSetup

func (p *PKI) CheckSetup() error

Validate all components of the PKI infrastructure are properly configured

func (*PKI) GenerateClientCertificate

func (p *PKI) GenerateClientCertificate(hosts []string) (err error)

func (*PKI) GetClientTLSConfig

func (p *PKI) GetClientTLSConfig() (*tls.Config, error)

func (*PKI) GetServerTLSConfig

func (p *PKI) GetServerTLSConfig() (*tls.Config, error)

func (*PKI) ImportCA

func (p *PKI) ImportCA(name string, certPath string) error

func (*PKI) ImportClientCertAndKey

func (p *PKI) ImportClientCertAndKey(certPath string, keyPath string) error

Overrides the default client certificate with a new one

func (*PKI) OutputCACert

func (p *PKI) OutputCACert() (string, error)

func (*PKI) OutputCAKey

func (p *PKI) OutputCAKey() (string, error)

func (*PKI) OutputClientCert

func (p *PKI) OutputClientCert() (string, error)

func (*PKI) OutputClientKey

func (p *PKI) OutputClientKey() (string, error)

func (*PKI) RemovePKI

func (p *PKI) RemovePKI() error

func (*PKI) SetupPKI

func (p *PKI) SetupPKI(caHost string) error

Sets up the PKI infrastructure for client / server communications This involves creating directories, CAs, and client/server certs

type Pki

type Pki struct {
	sync.Mutex
	ClientTlsConfig *tls.Config
	ServerTlsConfig *tls.Config
	BaseDir         string
}
var PkiConfig Pki

func (*Pki) SetBaseDir

func (m *Pki) SetBaseDir(baseDir string)

func (*Pki) SetClientTLSConfig

func (m *Pki) SetClientTLSConfig(config *tls.Config)

func (*Pki) SetServerTLSConfig

func (m *Pki) SetServerTLSConfig(config *tls.Config)

Jump to

Keyboard shortcuts

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