selfsigned

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cert

type Cert struct {
	// Path to the SSL certificates.
	CACertPath, CertPath string

	// Path to the private keys for the SSL certificates.
	CAKeyPath, KeyPath string
}

func NewSelfSignedCert

func NewSelfSignedCert(t *testing.T, opts ...CertOpt) *Cert

func (*Cert) ClientTLSConfig

func (c *Cert) ClientTLSConfig(t *testing.T, insecure, addCert bool) *tls.Config

func (*Cert) ServerTLSConfig

func (c *Cert) ServerTLSConfig(t *testing.T) *tls.Config

type CertOpt

type CertOpt func(*CertOptions)

func WithCASubject

func WithCASubject(organization, commonName string) CertOpt

func WithCombinedFile

func WithCombinedFile() CertOpt

func WithDNSName

func WithDNSName(dnsName string) CertOpt

func WithExtKeyUsage added in v1.13.0

func WithExtKeyUsage(eku ...x509.ExtKeyUsage) CertOpt

WithExtKeyUsage replaces the leaf certificate's extended key usages, which default to server and client authentication. Passing no usages omits the extension entirely, leaving the certificate unrestricted.

func WithIPAddr

func WithIPAddr(ipAddr net.IP) CertOpt

func WithNoDefaultIPAddrs

func WithNoDefaultIPAddrs() CertOpt

func WithNotAfter

func WithNotAfter(notAfter time.Time) CertOpt

func WithNotBefore

func WithNotBefore(notBefore time.Time) CertOpt

type CertOptions

type CertOptions struct {
	// DNSNames for cert
	DNSNames []string

	// IP Addresses for cert
	IPAddrs []net.IP

	// SkipDefaultIPAddrs indicates if the default IPAddrs should be skipped if IPAddrs is not set.
	SkipDefaultIPAddrs bool

	// NotBefore for certificate
	NotBefore time.Time

	// NotAfter for certificate
	NotAfter time.Time

	// CombinedFile indicates if the certificate and key should be combined into a single file
	CombinedFile bool

	// CAOrganization sets the CA certificate's Subject.Organization field
	CAOrganization string

	// CACommonName sets the CA certificate's Subject.CommonName field
	CACommonName string

	// ExtKeyUsage replaces the leaf certificate's extended key usages. It is
	// only consulted when ExtKeyUsageSet is true, so that an empty value can
	// omit the extension entirely rather than mean "unset".
	ExtKeyUsage []x509.ExtKeyUsage

	// ExtKeyUsageSet indicates ExtKeyUsage was configured with WithExtKeyUsage.
	ExtKeyUsageSet bool
}

Jump to

Keyboard shortcuts

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