Documentation
¶
Index ¶
- Constants
- func BootstrapCNFromName(name string) (string, error)
- func CNFromDeviceFingerprint(fingerprint string) (string, error)
- func DecryptKeyBytes(pemKeyEncrypted []byte, pw []byte) ([]byte, error)
- func EnsureKey(keyFile string) (crypto.PublicKey, crypto.PrivateKey, bool, error)
- func GetPEMBlock(pemKey []byte) (*pem.Block, error)
- func HashPublicKey(key crypto.PublicKey) ([]byte, error)
- func IsEncryptedPEMKey(pemKey []byte) (bool, error)
- func LoadKey(keyFile string) (crypto.PrivateKey, error)
- func MakeCSR(privateKey crypto.Signer, subjectName string) ([]byte, error)
- func NewKeyPair() (crypto.PublicKey, crypto.PrivateKey, error)
- func NewKeyPairWithHash() (crypto.PublicKey, crypto.PrivateKey, []byte, error)
- func PEMEncodeKey(key crypto.PrivateKey) ([]byte, error)
- func ParseCSR(csrPEM []byte) (*x509.CertificateRequest, error)
- func ParseKeyPEM(pemKey []byte) (crypto.PrivateKey, error)
- func TLSConfigForClient(caConfig, clientConfig *TLSCertificateConfig) (*tls.Config, error)
- func TLSConfigForServer(caConfig, serverConfig *TLSCertificateConfig) (*tls.Config, *tls.Config, *tls.Config, error)
- func WriteKey(keyPath string, key crypto.PrivateKey) error
- func WritePasswordEncryptedKey(keyPath string, key crypto.PrivateKey, password []byte) error
- type CA
- func (ca *CA) EnsureClientCertificate(certFile, keyFile string, subjectName string, expireDays int) (*TLSCertificateConfig, bool, error)
- func (ca *CA) EnsureServerCertificate(certFile, keyFile string, hostnames []string, expireDays int) (*TLSCertificateConfig, bool, error)
- func (ca *CA) IssueRequestedClientCertificate(csr *x509.CertificateRequest, expirySeconds int) ([]byte, error)
- func (ca *CA) MakeAndWriteServerCert(certFile, keyFile string, hostnames []string, expireDays int) (*TLSCertificateConfig, error)
- func (ca *CA) MakeClientCertificate(certFile, keyFile string, subject string, expiryDays int) (*TLSCertificateConfig, error)
- func (ca *CA) MakeServerCert(hostnames []string, expiryDays int, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error)
- type CertificateExtensionFunc
- type TLSCertificateConfig
Constants ¶
const AdminCommonName = "flightctl-admin"
const ClientBootstrapCommonName = "client-enrollment"
Wraps openshift/library-go/pkg/crypto to use ECDSA and simplify the interface
const ClientBootstrapCommonNamePrefix = "client-enrollment-"
const DeviceCommonNamePrefix = "device:"
Variables ¶
This section is empty.
Functions ¶
func BootstrapCNFromName ¶ added in v0.2.0
func CNFromDeviceFingerprint ¶
func DecryptKeyBytes ¶ added in v0.3.0
func IsEncryptedPEMKey ¶ added in v0.3.0
func NewKeyPair ¶
func NewKeyPair() (crypto.PublicKey, crypto.PrivateKey, error)
func NewKeyPairWithHash ¶
func PEMEncodeKey ¶
func PEMEncodeKey(key crypto.PrivateKey) ([]byte, error)
func ParseKeyPEM ¶
func ParseKeyPEM(pemKey []byte) (crypto.PrivateKey, error)
func TLSConfigForClient ¶
func TLSConfigForClient(caConfig, clientConfig *TLSCertificateConfig) (*tls.Config, error)
func TLSConfigForServer ¶
func WritePasswordEncryptedKey ¶ added in v0.3.0
func WritePasswordEncryptedKey(keyPath string, key crypto.PrivateKey, password []byte) error
this copies functionality from sigstore's cosign to encrypt the private key using functionality from secure systems lab, which relies on golang crypto's secretbox and scrypt. see: https://github.com/sigstore/cosign/blob/77f71e0d7470e31ed4ed5653fe5a7c8e3b283606/pkg/cosign/keys.go#L158 https://github.com/secure-systems-lab/go-securesystemslib/blob/7dd9eabdaf9ea98ba33653cdfbdec7057bd662fd/encrypted/encrypted.go#L158
Types ¶
type CA ¶
type CA struct {
Config *TLSCertificateConfig
SerialGenerator oscrypto.SerialGenerator
}
func MakeSelfSignedCA ¶
func (*CA) EnsureClientCertificate ¶
func (*CA) EnsureServerCertificate ¶
func (*CA) IssueRequestedClientCertificate ¶
func (ca *CA) IssueRequestedClientCertificate(csr *x509.CertificateRequest, expirySeconds int) ([]byte, error)
IssueRequestedClientCertificate issues a client certificate based on the provided Certificate Signing Request (CSR) and the desired expiration time in seconds. This currently processes both enrollment cert and management cert signing requests, which both are signed by the FC service's internal CA instance named 'ca'.
func (*CA) MakeAndWriteServerCert ¶
func (*CA) MakeClientCertificate ¶
func (*CA) MakeServerCert ¶
func (ca *CA) MakeServerCert(hostnames []string, expiryDays int, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error)
type CertificateExtensionFunc ¶
type CertificateExtensionFunc func(*x509.Certificate) error
type TLSCertificateConfig ¶
type TLSCertificateConfig oscrypto.TLSCertificateConfig
func GetClientCertificate ¶
func GetClientCertificate(certFile, keyFile string, subjectName string) (*TLSCertificateConfig, error)
func GetServerCert ¶
func GetServerCert(certFile, keyFile string, hostnames []string) (*TLSCertificateConfig, error)
func GetTLSCertificateConfig ¶
func GetTLSCertificateConfig(certFile, keyFile string) (*TLSCertificateConfig, error)
func (*TLSCertificateConfig) GetPEMBytes ¶
func (c *TLSCertificateConfig) GetPEMBytes() ([]byte, []byte, error)
func (*TLSCertificateConfig) WriteCertConfigFile ¶
func (c *TLSCertificateConfig) WriteCertConfigFile(certFile, keyFile string) error