func NewSpec() *Spec {
	return &Spec{
		Root:   Claim{},
		Interm: Claim{},
		Server: Claim{},
		Client: Claim{},
		RootPolicy: Policy{
			Match:    defaultRootPolicyMatch,
			Supplied: defaultRootPolicySupplied,
		},
		IntermPolicy: Policy{
			Match:    defaultIntermPolicyMatch,
			Supplied: defaultIntermPolicySupplied,
		},
		Metadata: Metadata{},
	}
}
NewSpec creates a new spec
package pki
import (
	"net"
	"path"
)
const (
	extKey     = ".key"
	extCert    = ".cert"
	extCSR     = ".csr"
	extCAKey   = ".ca.key"
	extCACert  = ".ca.cert"
	extCACSR   = ".ca.csr"
	extCAChain = ".ca.chain"
	defaultRootCASerial = int64(10)
	defaultRootCALength = 4096
	defaultRootCADays   = 20 * 365
	defaultIntermCASerial = int64(100)
	defaultIntermCALength = 4096
	defaultIntermCADays   = 10 * 365
	defaultServerCertSerial = int64(1000)
	defaultServerCertLength = 2048
	defaultServerCertDays   = 10 + 365
	defaultClientCertSerial = int64(10000)
	defaultClientCertLength = 2048
	defaultClientCertDays   = 10 + 30
	titleRoot   = "Root Certificate Authority"
	titleInterm = "Intermediate Certificate Authority"
	titleServer = "Server Certificate Authority"
	titleClient = "Client Certificate Authority"
)
var (
	defaultRootPolicyMatch    = []string{}
	defaultRootPolicySupplied = []string{"CommonName"}
	defaultIntermPolicyMatch    = []string{}
	defaultIntermPolicySupplied = []string{"CommonName"}
)
type (
	State struct {
		Root   Config `yaml:"root"`
		Interm Config `yaml:"intermediate"`
		Server Config `yaml:"server"`
		Client Config `yaml:"client"`
	}
	Config struct {
		Serial   int64  `yaml:"serial"`
		Length   int    `yaml:"length"`
		Days     int    `yaml:"days"`
		Password string `yaml:"-" secret:"required,6"`
	}
	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"`
		Metadata     Metadata `toml:"metadata"`
	}
	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"`
	}
	Policy struct {
		Match    []string `toml:"match"`
		Supplied []string `toml:"supplied" default:"CommonName"`
	}
	Metadata map[string][]string
	Cert struct {
		Type int
		Name string
	}
)
func NewState() *State {
	return &State{
		Root: Config{
			Serial: defaultRootCASerial,
			Length: defaultRootCALength,
			Days:   defaultRootCADays,
		},
		Interm: Config{
			Serial: defaultIntermCASerial,
			Length: defaultIntermCALength,
			Days:   defaultIntermCADays,
		},
		Server: Config{
			Serial: defaultServerCertSerial,
			Length: defaultServerCertLength,
			Days:   defaultServerCertDays,
		},
		Client: Config{
			Serial: defaultClientCertSerial,
			Length: defaultClientCertLength,
			Days:   defaultClientCertDays,
		},
	}
}