pki

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: ISC Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CertTypeRoot represents a root certificate authority
	CertTypeRoot = 1 + iota
	// CertTypeInterm represents an intermediate certificate authority
	CertTypeInterm
	// CertTypeServer represents a server certificate
	CertTypeServer
	// CertTypeClient represents a client certificate
	CertTypeClient
)
View Source
const (
	// DirRoot is the name of directory for root certificate authority
	DirRoot = "root"
	// DirInterm is the name of directory for intermediate certificate authorities
	DirInterm = "intermediate"
	// DirServer is the name of directory for server certificates
	DirServer = "server"
	// DirClient is the name of directory for client certificates
	DirClient = "client"
	// DirCSR is the name of directory for certificate signing requests
	DirCSR = "csr"

	// FileState is the name of state file
	FileState = "state.yaml"
	// FileSpec is the name of spec file
	FileSpec = "spec.toml"
)

Variables

This section is empty.

Functions

func CleanupWorkspace

func CleanupWorkspace() error

CleanupWorkspace removes all directories and files in a workspace

func LoadWorkspace

func LoadWorkspace() (*State, *Spec, error)

LoadWorkspace loads an existing workspace

func NewWorkspace

func NewWorkspace(state *State, spec *Spec) error

NewWorkspace creates a new workspace in current directory

func SaveSpec

func SaveSpec(spec *Spec, file string) error

SaveSpec writes spec to a TOML file

func SaveState

func SaveState(state *State, file string) error

SaveState writes state to a YAML file

func SaveWorkspace

func SaveWorkspace(state *State, spec *Spec) error

SaveWorkspace saves changes to an existing workspace

Types

type Claim

type Claim struct {
	CommonName         string   `toml:"-"`
	Country            []string `toml:"country"`
	Province           []string `toml:"province"`
	Locality           []string `toml:"locality"`
	Organization       []string `toml:"organization"`
	OrganizationalUnit []string `toml:"organizational_unit"`
	DNSName            []string `toml:"dns_name"`
	IPAddress          []net.IP `toml:"ip_address"`
	EmailAddress       []string `toml:"email_address"`
	StreetAddress      []string `toml:"street_address"`
	PostalCode         []string `toml:"postal_code"`
}

Claim represents the subtype for an identity claim

func (Claim) Clone

func (c Claim) Clone() Claim

Clone return a deep copy of claim

type Config

type Config struct {
	Serial   int64  `yaml:"serial"`
	Length   int    `yaml:"length"`
	Days     int    `yaml:"days"`
	Password string `yaml:"-" secret:"required,6"`
}

Config represents the subtype for configurations

type Manager

type Manager interface {
	GenCert(Config, Claim, Metadata) error
	GenCSR(Config, Claim, Metadata) error
	SignCSR(Config, Metadata, Config, Metadata, TrustFunc) error
	VerifyCert(Metadata, Metadata, string) error
}

Manager provides methods for managing certificates

func NewX509Manager

func NewX509Manager() Manager

NewX509Manager creates a new X509Manager

type Metadata

type Metadata struct {
	Name     string
	CertType int
}

Metadata represents the type for metadata about a certificate

func (Metadata) CSRPath

func (md Metadata) CSRPath() string

CSRPath returns certificate signing request file path

func (Metadata) CertPath

func (md Metadata) CertPath() string

CertPath returns cert file path

func (Metadata) ChainPath

func (md Metadata) ChainPath() string

ChainPath returns certificate chain file path

func (Metadata) KeyPath

func (md Metadata) KeyPath() string

KeyPath returns key file path

func (Metadata) Title

func (md Metadata) Title() string

Title returns a descriptive title

type Policy

type Policy struct {
	Match    []string `toml:"match"`
	Supplied []string `toml:"supplied"`
}

Policy represents the subtype for a policy

type Spec

type Spec struct {
	Root         Claim  `toml:"root"`
	Interm       Claim  `toml:"intermediate"`
	Server       Claim  `toml:"server"`
	Client       Claim  `toml:"client"`
	RootPolicy   Policy `toml:"root_policy"`
	IntermPolicy Policy `toml:"intermediate_policy"`
}

Spec represents the type for specs

func LoadSpec

func LoadSpec(file string) (*Spec, error)

LoadSpec reads and parses spec from a TOML file

func NewSpec

func NewSpec() *Spec

NewSpec creates a new spec

func (*Spec) ClaimFor

func (s *Spec) ClaimFor(certType int) (Claim, bool)

ClaimFor returns claim for a certificate type

func (*Spec) PolicyFor

func (s *Spec) PolicyFor(certType int) (Policy, bool)

PolicyFor returns policy for a certificate type

type State

type State struct {
	Root   Config `yaml:"root"`
	Interm Config `yaml:"intermediate"`
	Server Config `yaml:"server"`
	Client Config `yaml:"client"`
}

State represents the type for state

func LoadState

func LoadState(file string) (*State, error)

LoadState reads and parses state from a YAML file

func NewState

func NewState() *State

NewState creates a new state

func (*State) ConfigFor

func (s *State) ConfigFor(certType int) (Config, bool)

ConfigFor returns config for a certificate type

type TrustFunc

type TrustFunc func(*x509.Certificate, *x509.CertificateRequest) bool

TrustFunc is the function for determing if a ca can sign a csr

func PolicyTrustFunc

func PolicyTrustFunc(policy Policy) TrustFunc

PolicyTrustFunc returns a TrustFunc using Policy

Jump to

Keyboard shortcuts

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