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 hexaKeyTool command to call this routine.
go run cmd/hexaKeyTool
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 ¶
const ( EnvCertOrg string = "HEXA_CERT_ORG" EnvCertCountry string = "HEXA_CERT_COUNTRY" EnvCertProv string = "HEXA_CERT_PROV" EnvCertLocality string = "HEXA_CERT_LOCALITY" EnvCertCaPrivKey string = "HEXA_CA_KEYFILE" // The location of a private key used to generate server keys EnvCertCaPubKey string = "HEXA_CA_CERT" EnvCertDirectory string = "HEXA_CERT_DIRECTORY" // The location where keys are stored. EnvServerCert string = "HEXA_SERVER_CERT" EnvServerKey string = "HEXA_SERVER_KEY_PATH" EnvServerDNS string = "HEXA_SERVER_DNS_NAME" EnvAutoCreate string = "HEXA_AUTO_SELFSIGN" )
Variables ¶
This section is empty.
Functions ¶
func CheckCaInstalled ¶
CheckCaInstalled will check if a CA certificate has been installed in the http.Client or if nil, the system cert pool
Types ¶
type KeyConfig ¶
type KeyConfig struct { CaKeyFile string // The file containing a PEM encoded PKCS1 private key CaCertFile string CaPrivKey *rsa.PrivateKey CertDir string // This is the directory where generated keys are output PkixName pkix.Name ServerCertPath string ServerKeyPath string CaConfig *x509.Certificate // contains filtered or unexported fields }
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 (KeyConfig) GenerateClientKeys ¶
func (KeyConfig) InitializeKeys ¶
InitializeKeys 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).