pki

package
v0.0.0-...-0deab39 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelfSignedCert

func SelfSignedCert(opts ...Opt) (tls.Certificate, error)

SelfSignedCert will generate a self-signed certificate with all the passed options (see all Opt implementations).

Return value is a *tls.Certificate, which will contain the X509 certificate struct:

tlsCert := &tls.Certificate {
		Certificate: [][]byte{x509Cert.Raw},
		PrivateKey:  privateKey,
		Leaf:        x509Cert,     // The x509 certificate struct.
}

The resultant *tls.Certificate can be used directly in a *tls.Config of the server.

Types

type Opt

type Opt func(cert *x509.Certificate)

Opt represents a parameter for creating a new self-signed certificate. See implementations below.

func WithCertCommonName

func WithCertCommonName(cn string) Opt

func WithCertDNSNames

func WithCertDNSNames(dnsNames []string) Opt

func WithCertIpAddresses

func WithCertIpAddresses(ips []string) Opt

func WithCertNotAfter

func WithCertNotAfter(t time.Time) Opt

func WithCertNotBefore

func WithCertNotBefore(t time.Time) Opt

func WithCertOrganization

func WithCertOrganization(org []string) Opt

func WithCertSerialNumber

func WithCertSerialNumber(n int64) Opt

Jump to

Keyboard shortcuts

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