generateCertificate

package
v2.0.0-...-057b331 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCSR

func GenerateCSR(cfg Configuration, privateKey *ecdsa.PrivateKey) ([]byte, error)

GenerateCSR creates CSR according to configuration.

func GenerateCert

func GenerateCert(cfg Configuration, privateKey *ecdsa.PrivateKey, signerCA []*x509.Certificate, signerCAKey *ecdsa.PrivateKey) ([]byte, error)

func GenerateIdentityCSR

func GenerateIdentityCSR(cfg Configuration, deviceID string, privateKey *ecdsa.PrivateKey) ([]byte, error)

GenerateIdentityCSR creates identity CSR according to configuration.

func GenerateIdentityCert

func GenerateIdentityCert(cfg Configuration, deviceID string, privateKey *ecdsa.PrivateKey, signerCA []*x509.Certificate, signerCAKey *ecdsa.PrivateKey) ([]byte, error)

func GenerateIntermediateCA

func GenerateIntermediateCA(cfg Configuration, privateKey *ecdsa.PrivateKey, signerCA []*x509.Certificate, signerCAKey *ecdsa.PrivateKey) ([]byte, error)

func GenerateRootCA

func GenerateRootCA(cfg Configuration, privateKey *ecdsa.PrivateKey) ([]byte, error)

func NewIdentityCSRTemplate

func NewIdentityCSRTemplate(deviceID string) (*x509.CertificateRequest, error)

func OidFromExtKeyUsage

func OidFromExtKeyUsage(eku x509.ExtKeyUsage) (oid asn1.ObjectIdentifier, ok bool)

Types

type Configuration

type Configuration struct {
	Subject struct {
		Country            []string `yaml:"country" long:"c" description:"to set more values repeat option with parameter"`
		Organization       []string `yaml:"organization" long:"o" description:"to set more values repeat option with parameter"`
		OrganizationalUnit []string `yaml:"organizationUnit" long:"ou" description:"to set more values repeat option with parameter"`
		Locality           []string `yaml:"locality" long:"l" description:"to set more values repeat option with parameter"`
		CommonName         string   `yaml:"commonName" long:"cn"`
		Province           []string `yaml:"province" long:"p" description:"to set more values repeat option with parameter"`
		StreetAddress      []string `yaml:"streetAddress" long:"sa" description:"to set more values repeat option with parameter"`
		PostalCode         []string `yaml:"postalCode" long:"pc" description:"to set more values repeat option with parameter"`
		SerialNumber       string   `yaml:"serialNumber" long:"sn"`
	} `yaml:"subject" group:"Subject" namespace:"subject"`
	SubjectAlternativeName struct {
		DNSNames    []string `yaml:"dnsNames" long:"domain" description:"to set more values repeat option with parameter"`
		IPAddresses []string `yaml:"ipAddresses" long:"ip" description:"to set more values repeat option with parameter"`
	} `yaml:"subjectAlternativeName" group:"Subject Alternative Name" namespace:"san"`
	BasicConstraints struct {
		Ignore     bool `yaml:"ignore" long:"ignore"  description:"bool, don't set basic constraints"`
		MaxPathLen int  `yaml:"maxPathLen" long:"maxPathLen" default:"-1"  description:"int, -1 means unlimited"`
	} `yaml:"basicConstraints" group:"Basic Constraints" namespace:"basicConstraints"`
	ValidFrom          string        `yaml:"validFrom" long:"validFrom" default:"now" description:"valid from time, format in RFC3339 (eg:2014-11-12T11:45:00Z)"`
	ValidFor           time.Duration `yaml:"validFor" long:"validFor" default:"8760h" description:"duration, format in NUMh"`
	KeyUsages          []string      `` /* 138-byte string literal not displayed */
	ExtensionKeyUsages []string      `` /* 132-byte string literal not displayed */
}

func (Configuration) AsnExtensionKeyUsages

func (cfg Configuration) AsnExtensionKeyUsages() ([]asn1.ObjectIdentifier, error)

func (Configuration) AsnKeyUsages

func (cfg Configuration) AsnKeyUsages() (asn1.BitString, error)

func (Configuration) ToIPAddresses

func (cfg Configuration) ToIPAddresses() ([]net.IP, error)

func (Configuration) ToPkixName

func (cfg Configuration) ToPkixName() pkix.Name

func (Configuration) ToValidFrom

func (cfg Configuration) ToValidFrom() (time.Time, error)

func (Configuration) X509ExtKeyUsages

func (cfg Configuration) X509ExtKeyUsages() ([]x509.ExtKeyUsage, []asn1.ObjectIdentifier, error)

func (Configuration) X509KeyUsages

func (cfg Configuration) X509KeyUsages() (x509.KeyUsage, error)

Jump to

Keyboard shortcuts

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