testcert

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Zlib Imports: 10 Imported by: 0

Documentation

Overview

Package testcert provides utilities for generating self-signed TLS certificates for testing purposes. It can generate a root CA and derive server certificates from it, suitable for testing SQL Server TLS connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CA

type CA struct {
	Cert       *x509.Certificate
	PrivateKey *ecdsa.PrivateKey
	CertPEM    []byte
	KeyPEM     []byte
}

CA represents a Certificate Authority that can sign certificates.

func GenerateCA

func GenerateCA(commonName string, validFor time.Duration) (*CA, error)

GenerateCA creates a new self-signed root Certificate Authority.

func (*CA) CertPool

func (ca *CA) CertPool() *x509.CertPool

CertPool returns a certificate pool containing the CA certificate, suitable for use as RootCAs in tls.Config.

func (*CA) GenerateServerCert

func (ca *CA) GenerateServerCert(commonName string, hosts []string, ips []net.IP, validFor time.Duration) (*ServerCert, error)

GenerateServerCert creates a server certificate signed by the CA. The certificate will be valid for the given hostnames and IP addresses.

type ServerCert

type ServerCert struct {
	Cert       *x509.Certificate
	PrivateKey *ecdsa.PrivateKey
	CertPEM    []byte
	KeyPEM     []byte
	CA         *CA
}

ServerCert represents a server certificate signed by a CA.

Jump to

Keyboard shortcuts

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