v1

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Implements version 1 of the configuration parser.

It applies some defaults to the configurations: - Default Key Algorithm: EC P-256 - Default Signature Algorithm: ECDSAWithSHA256 for EC; RSAWIthSHA256 for RSA. - Default certificate validity: 5 years, starting from the current point in time.

Index

Constants

View Source
const (
	DigitalSignature string = "digitalSignature"
	NonRepudiation   string = "nonRepudiation"
	KeyEncipherment  string = "keyEncipherment"
	DataEncipherment string = "dataEncipherment"
	KeyAgreement     string = "keyAgreement"
	KeyCertSign      string = "keyCertSign"
	CRLSign          string = "crlSign"
)
View Source
const (
	ServerAuth      string = "serverAuth"
	ClientAuth      string = "clientAuth"
	CodeSigning     string = "codeSigning"
	EmailProtection string = "emailProtection"
	TimeStamping    string = "timeStamping"
	OcspSigning     string = "OCSPSigning"
)

Variables

View Source
var DurationSchemaString string

Functions

This section is empty.

Types

type Admission added in v0.1.0

type Admission struct {
	AdmissionAuthority GeneralName       `json:"admissionAuthority"`
	Admissions         []SingleAdmission `json:"admissions"`
}

type AdmissionExtension added in v0.1.0

type AdmissionExtension struct {
	Raw      string     `json:"raw"`
	Critical bool       `json:"critical"`
	Content  *Admission `json:"content"`
}

func (AdmissionExtension) Builder added in v0.1.0

func (AdmissionExtension) Oid added in v0.1.0

type AnyExtension

type AnyExtension struct {
	*SubjectKeyIdentifier `json:"subjectKeyIdentifier"`
	*KeyUsage             `json:"keyUsage"`
	*SubjectAltName       `json:"subjectAlternativeName"`
	*BasicConstraints     `json:"basicConstraints"`
	*CertPolicies         `json:"certificatePolicies"`
	*AuthInfoAccess       `json:"authorityInformationAccess"`
	*AuthKeyId            `json:"authorityKeyIdentifier"`
	*ExtKeyUsage          `json:"extendedKeyUsage"`
	*AdmissionExtension   `json:"admission"`
	*CustomExtension      `json:"custom"`
	Optional              bool `json:"optional"`
	Override              bool `json:"override"`
}

Struct for unmarshaling JSON/YAML extensions. The config expects a list of objects, where each object has only one key-value pair. This ensures readability and preserves the order of extensions while still not having to unmarshal everything by hand. This is also enforced through the schema.

This means that only one pointer is not nil after parsing. We later use reflection to find out, which one it is and return the appropriate pointer value as a config.ExtensionConfig.

This struct must only include exactly one config.ExtensionConfig implementation for each extension.

To add an extension, simply write your config.ExtensionConfig implementation and add a pointer to this struct.

type AuthInfoAccess

type AuthInfoAccess struct {
	Raw      string           `json:"raw"`
	Critical bool             `json:"critical"`
	Content  []SingleAuthInfo `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (AuthInfoAccess) Builder

func (a AuthInfoAccess) Builder() (cert.ExtensionBuilder, error)

func (AuthInfoAccess) Oid

type AuthKeyId

type AuthKeyId struct {
	Raw      string           `json:"raw"`
	Critical bool             `json:"critical"`
	Content  AuthKeyIdContent `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (AuthKeyId) Builder

func (a AuthKeyId) Builder() (cert.ExtensionBuilder, error)

func (AuthKeyId) Oid

func (a AuthKeyId) Oid() (asn1.ObjectIdentifier, error)

type AuthKeyIdContent

type AuthKeyIdContent struct {
	Id string `json:"id"`
}

type BasicConstraints

type BasicConstraints struct {
	Raw      string               `json:"raw"`
	Critical bool                 `json:"critical"`
	Content  *BasicConstraintsObj `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (BasicConstraints) Builder

func (BasicConstraints) Oid

type BasicConstraintsObj

type BasicConstraintsObj struct {
	Ca      bool `json:"ca"`
	PathLen int  `json:"pathLen"`
}

type CertConfig

type CertConfig struct {
	Alias              string         `json:"alias"`
	Version            int            `json:"version"`
	Profile            string         `json:"profile"`
	SerialNumber       int64          `json:"serialNumber"`
	IssuerUniqueId     string         `json:"issuerUniqueId"`
	SubjectUniqueId    string         `json:"subjectUniqueId"`
	Subject            string         `json:"subject"`
	Issuer             string         `json:"issuer"`
	Validity           CertValidity   `json:"validity"`
	KeyAlgorithm       string         `json:"keyAlgorithm"`
	SignatureAlgorithm string         `json:"signatureAlgorithm"`
	Extensions         []AnyExtension `json:"extensions"`
	Manipulations      Manipulations  `json:"manipulations"`
}

Struct for YAML/JSON marshaling.

type CertPolicies

type CertPolicies struct {
	Raw      string       `json:"raw"`
	Critical bool         `json:"critical"`
	Content  []CertPolicy `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (CertPolicies) Builder

func (c CertPolicies) Builder() (cert.ExtensionBuilder, error)

func (CertPolicies) Oid

type CertPolicy

type CertPolicy struct {
	Oid        string             `json:"oid"`
	Qualifiers []PolicyQualifiers `json:"qualifiers"`
}

type CertValidity

type CertValidity struct {
	From     string `json:"from"`
	Until    string `json:"until"`
	Duration string `json:"duration"`
}

Struct for YAML/JSON marshaling.

type CfgFileType

type CfgFileType int

type CustomExtension

type CustomExtension struct {
	OidStr   string `json:"oid"`
	Raw      string `json:"raw"`
	Critical bool   `json:"critical"`
}

JSON/YAML representation for this custom extensions. Also implements config.ExtensionConfig

func (CustomExtension) Builder

func (c CustomExtension) Builder() (cert.ExtensionBuilder, error)

func (CustomExtension) Oid

type ExtKeyUsage

type ExtKeyUsage struct {
	Raw      string   `json:"raw"`
	Critical bool     `json:"critical"`
	Content  []string `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (ExtKeyUsage) Builder

func (e ExtKeyUsage) Builder() (cert.ExtensionBuilder, error)

func (ExtKeyUsage) Oid

type ExtensionType

type ExtensionType int
const (
	TypeIllegal ExtensionType = iota
	TypeSubjectKeyIdentifier
	TypeKeyUsage
	TypeSubjectAltName
	TypeBasicConstraints
	TypeCertPolicies
	TypeAuthInfoAccess
	TypeAuthKeyId
	TypeAdmission
	TypeExtKeyUsage
	TypeCustomExtension
)

type GeneralName added in v0.1.0

type GeneralName struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

type KeyUsage

type KeyUsage struct {
	Raw      string   `json:"raw"`
	Critical bool     `json:"critical"`
	Content  []string `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (KeyUsage) Builder

func (k KeyUsage) Builder() (cert.ExtensionBuilder, error)

func (KeyUsage) Oid

func (k KeyUsage) Oid() (asn1.ObjectIdentifier, error)

type Manipulations added in v0.2.0

type Manipulations struct {
	Version      *int   `json:".version"`
	OuterSigAlg  string `json:".signatureAlgorithm"`
	SigValue     string `json:".signatureValue"`
	TbsSig       string `json:".tbs.signature"`
	TbsPubKeyAlg string `json:".tbs.subjectPublicKey.algorithm"`
	TbsPubKey    string `json:".tbs.subjectPublicKey.subjectPublicKey"`
}

func (Manipulations) Apply added in v0.2.0

type NamingAuthority added in v0.1.0

type NamingAuthority struct {
	Oid  string `json:"oid"`
	Url  string `json:"url"`
	Text string `json:"text"`
}

type PolicyQualifiers

type PolicyQualifiers struct {
	Cps         string `json:"cps"`
	*UserNotice `json:"userNotice"`
}

type ProfessionInfo added in v0.1.0

type ProfessionInfo struct {
	NamingAuthority    `json:"namingAuthority"`
	ProfessionItems    []string `json:"professionItems"`
	ProfessionOids     []string `json:"professionOids"`
	RegistrationNumber string   `json:"registrationNumber"`
	AddProfessionInfo  string   `json:"addProfessionInfo"`
}

type Profile

type Profile struct {
	ProfileName       string                          `json:"name"`
	Version           int                             `json:"version"`
	Validity          CertValidity                    `json:"validity"`
	SubjectAttributes config.ProfileSubjectAttributes `json:"subjectAttributes"`
	Extensions        []AnyExtension                  `json:"extensions"`
}

Struct for YAML/JSON marshaling.

type SingleAdmission added in v0.1.0

type SingleAdmission struct {
	AdmissionAuthority GeneralName `json:"admissionAuthority"`
	NamingAuthority    `json:"namingAuthority"`
	ProfessionInfos    []ProfessionInfo `json:"professionInfos"`
}

type SingleAuthInfo

type SingleAuthInfo struct {
	Ocsp string `json:"ocsp"`
}

type SubjAltNameComponent

type SubjAltNameComponent struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

type SubjectAltName

type SubjectAltName struct {
	Raw      string                 `json:"raw"`
	Critical bool                   `json:"critical"`
	Content  []SubjAltNameComponent `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (SubjectAltName) Builder

func (s SubjectAltName) Builder() (cert.ExtensionBuilder, error)

func (SubjectAltName) Oid

type SubjectKeyIdentifier

type SubjectKeyIdentifier struct {
	Raw      string `json:"raw"`
	Critical bool   `json:"critical"`
	Content  string `json:"content"`
}

JSON/YAML representation for this extension. Also implements config.ExtensionConfig

func (SubjectKeyIdentifier) Builder

func (SubjectKeyIdentifier) Oid

type UserNotice

type UserNotice struct {
	Organization string `json:"organization"`
	Numbers      []int  `json:"numbers"`
	Text         string `json:"text"`
}

type V1Configurator

type V1Configurator struct{}

The implementor of config.Configurator for version 1.

func (V1Configurator) CertificateExample

func (v V1Configurator) CertificateExample() string

func (V1Configurator) ParseConfiguration

func (v V1Configurator) ParseConfiguration(s string) (any, error)

Implements ParseConfiguration from config.Configurator. It unmarshals the provided string and generate the appropriate configuration object with the stated defaults.

func (V1Configurator) ProfileExample

func (v V1Configurator) ProfileExample() string

Jump to

Keyboard shortcuts

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