keysupport

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package keysupport is used to generate self-signed keys for testing purposes.

This code was pulled and modified from the following resources: - https://gist.github.com/shaneutt/5e1995295cff6721c89a71d13a71c251 - https://shaneutt.com/blog/golang-ca-and-signed-cert-go/.

USAGE:

Use the genKeys command to call this routine.

go run cmd/genKeys

This will generate a CA cert/key pair and use that to sign Server cert/key pair and Client cert/key pair.

Use these certs for tests such as websupport_test and orchestrator_test.

Index

Constants

View Source
const (
	EnvCertOrg       string = "HEXA_CERT_ORG"
	EnvCertCountry   string = "HEXA_CERT_COUNTRY"
	EnvCertProv      string = "HEXA_CERT_PROV"
	EnvCertLocality  string = "HEXA_CERT_LOCALITY"
	EnvCertCaKey     string = "HEXA_CA_KEYFILE"     // The location of a private key used to generate server keys
	EnvCertDirectory string = "HEXA_CERT_DIRECTORY" // The location where keys are stored.
	EnvServerCert    string = "SERVER_CERT"
	EnvServerKey     string = "SERVER_KEY_PATH"
	EnvAutoCreate    string = "HEXA_AUTO_SELFSIGN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyConfig

type KeyConfig struct {
	KeyFile        string // The file containing a PEM encoded PKCS1 private key
	CertDir        string // This is the directory where generated keys are output
	PkixName       pkix.Name
	ServerCertPath string
	ServerKeyPath  string
}

func GetKeyConfig

func GetKeyConfig() KeyConfig

GetKeyConfig reads environment variables and sets up configuration parameters in KeyConfig struct. Note that if no environment variables are set, the default directory is the current directory plus "./.certs". When running in docker-compose as a minimum, HEXA_CERT_DIRECTORY should be set.

func (KeyConfig) CertDirExists

func (config KeyConfig) CertDirExists() bool

func (KeyConfig) CreateSelfSignedKeys

func (config KeyConfig) CreateSelfSignedKeys() (err error)

CreateSelfSignedKeys creates a set of self signed keys and writes them out to the directory in KeyConfig.CertDir This includes: Certificate Authority Certificate and Key (ca-cert/ca-key), Server certificate (server-cert.pem) and key (server-key.pem), and a client certificate (client-cert.pem) and key (client-key.pem).

func (KeyConfig) RootKeyExists

func (config KeyConfig) RootKeyExists() bool

func (KeyConfig) ServerKeyExists

func (config KeyConfig) ServerKeyExists() bool

Jump to

Keyboard shortcuts

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