tls

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gencert generates a certificate authority (CA) and a server certificate signed by it.

Index

Constants

View Source
const (
	CaOrganization      = "F5 Inc. CA"
	CertOrganization    = "F5 Inc."
	CertFilePermissions = 0o600
	KeyFilePermissions  = 0o600
)

Predefined constants for Org and file permissions

Variables

This section is empty.

Functions

func DoesCertAlreadyExist

func DoesCertAlreadyExist(certPath string) (bool, error)

Returns true if a valid certificate is found at certPath

func GenerateCA

func GenerateCA(now time.Time, caCertPath string) (*x509.Certificate, *ecdsa.PrivateKey, error)

Generates a CA, returns x509 Certificate and private key for signing server certificates

func GenerateCertificate

func GenerateCertificate(req *CertReq) (*x509.Certificate, []byte, error)

Returns x509 Certificate object and bytes in PEM format

func GenerateServerCerts

func GenerateServerCerts(hostnames []string, caPath, certPath, keyPath string) (existingCert bool, err error)

GenerateServerCerts creates a server CA, Cert and Key and writes them to specified destinations. Hostnames are a list of subject alternative names. If cert files are already present, does nothing, returns true.

Types

type CertReq

type CertReq struct {
	Template   *x509.Certificate
	Parent     *x509.Certificate
	PublicKey  *ecdsa.PublicKey
	PrivateKey *ecdsa.PrivateKey
}

CertReq contains a ECDSA key pair and 2 x509.Certificate templates, a server and parent. When generating a CA, template and parent are identical, making the CA "self-signed". When generating a server certificate, the `parent` is the CA template and `template` is the server.

Jump to

Keyboard shortcuts

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