keyStore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllTypes contains all possible variants of Type.

Functions

func LoadCertificateFromFile added in v0.1.6

func LoadCertificateFromFile(filename string) (*x509.Certificate, error)

LoadCertificateFromFile loads a certificate from the given filename and returns it.

Types

type Config

type Config struct {
	// @default generated
	//
	// Defines the type of the instance keyStore.
	Type Type `json:"type" yaml:"type"`

	// @default ""
	//
	// Defines the pemFile which contains the key and certificate to be used.
	// This has to be of type PEM and has to contain the certificate and private key.
	// Currently only private keys of type RSA are supported.
	//
	// This property is only evaluated and required if {@ref #Type type} is set to
	// {@ref .Type#FromFile fromFile}.
	PemFile values.String `json:"pemFile,omitempty" yaml:"pemFile"`

	// @default "algorithm:`rsa` bits:`1024`"
	//
	// Defines some hints, for example to store in the format “[<key:`value`>...]“.
	// Possible hints are:
	//
	// * “algorithm“: Algorithm to be used to create new keys. Currently only “rsa“ is supported.
	// * “bits“: Number of bits to create a new key with.
	Hints values.String `json:"hints,omitempty" yaml:"hints"`

	// @default ""
	//
	// File where trusted certificates are stored in. This has to be in PEM format.
	CaFile values.String `json:"caFile,omitempty" yaml:"caFile"`
}

Description

Defines the keyStore of caretakerd.

func NewConfig

func NewConfig() Config

NewConfig creates a new instance of Config.

func (Config) GetHintsArgument added in v0.1.6

func (instance Config) GetHintsArgument(key string) string

GetHintsArgument returns hints argument content for the given key. If there is no hint for this key and empty string is returned.

func (Config) Validate

func (instance Config) Validate() error

Validate validates an action on this object and returns an error object if there are any.

type KeyStore

type KeyStore struct {
	// contains filtered or unexported fields
}

KeyStore represents a keystore that holds certificates, CAs and private keys.

func NewKeyStore

func NewKeyStore(enabled bool, conf Config) (*KeyStore, error)

NewKeyStore create an new instance of KeyStore.

func (KeyStore) CA added in v0.1.6

func (instance KeyStore) CA() []*x509.Certificate

CA returns all contained CAs of this KeyStore.

func (KeyStore) Config

func (instance KeyStore) Config() Config

Config returns the Config instance this KeyStore was created with.

func (KeyStore) GeneratePem

func (instance KeyStore) GeneratePem(name string) ([]byte, *x509.Certificate, error)

GeneratePem generates a new PEM with the config of the current KeyStore instance and returns it. This PEM will be stored in the KeyStore instance.

func (KeyStore) IsCA

func (instance KeyStore) IsCA() bool

IsCA returns "true" if the contained certificate could be used to create new certificates.

func (KeyStore) IsEnabled

func (instance KeyStore) IsEnabled() bool

IsEnabled returns "true" if this KeyStore is configured and usable.

func (KeyStore) PEM added in v0.1.6

func (instance KeyStore) PEM() []byte

PEM returns the contained PEM instance of this KeyStore. If there is no PEM the result is empty.

func (KeyStore) Type

func (instance KeyStore) Type() Type

Type returns the Type of this KeyStore.

type Type

type Type int

Description

Represents the type of the keyStore.

const (
	// @id generated
	// Indicates that caretakerd have to generate its own keyStore on startup.
	// This is the best solution in most cases.
	Generated Type = 0

	// @id fromFile
	// Load keyStore from a provided PEM file.
	// If this instance type is selected, the instance file have to be provided.
	FromFile Type = 1

	// @id fromEnvironment
	// Load the KeyStore from the environment variable “CTD_PEM“ in PEM format.
	// If this instance type is selected, the instance variable have to be provided.
	FromEnvironment Type = 2
)

func (Type) CheckedString

func (instance Type) CheckedString() (string, error)

CheckedString is like String but also returns an optional error if there are any validation errors.

func (Type) IsConsumingCAFile added in v0.1.6

func (instance Type) IsConsumingCAFile() bool

IsConsumingCAFile returns "true" if the KeyStore instance created with this type can consume a CA bundle file.

func (Type) IsGenerating

func (instance Type) IsGenerating() bool

IsGenerating returns "true" if the KeyStore instance created with this type will be generated.

func (Type) IsTakingFilename

func (instance Type) IsTakingFilename() bool

IsTakingFilename returns "true" if the KeyStore instance created with this type is created from file.

func (Type) MarshalJSON

func (instance Type) MarshalJSON() ([]byte, error)

MarshalJSON is used until json marshalling. Do not call this method directly.

func (Type) MarshalYAML

func (instance Type) MarshalYAML() (interface{}, error)

MarshalYAML is used until yaml marshalling. Do not call this method directly.

func (*Type) Set

func (instance *Type) Set(value string) error

Set sets the given string to current object from a string. Returns an error object if there are any problems while transforming the string.

func (Type) String

func (instance Type) String() string

func (*Type) UnmarshalJSON

func (instance *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON is used until json unmarshalling. Do not call this method directly.

func (*Type) UnmarshalYAML

func (instance *Type) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is used until yaml unmarshalling. Do not call this method directly.

func (Type) Validate

func (instance Type) Validate() error

Validate validates actions on this object and returns an error object there are any.

Jump to

Keyboard shortcuts

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