mkcert

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package mkcert is a library adaptation of https://github.com/FiloSottile/mkcert (which is intentionally not importable as a Go module). It creates and loads the local development CA in mkcert's CAROOT using mkcert's exact file format and naming, so the CA is fully shared with the mkcert tool: a CA created by mkcert is reused here, a CA created here works with "mkcert -install" and certificates issued by either are interchangeable.

The code is adapted from mkcert's cert.go and main.go: it returns errors instead of exiting, and the PKCS#12, CSR and client-certificate paths are removed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CAROOT

func CAROOT() string

CAROOT returns the mkcert CA directory, honoring the $CAROOT environment variable exactly like the mkcert tool.

Types

type CA

type CA struct {
	Cert *x509.Certificate
	// contains filtered or unexported fields
}

CA is the local development certificate authority stored in CAROOT.

func LoadOrCreateCA

func LoadOrCreateCA() (*CA, bool, error)

LoadOrCreateCA loads the CA from CAROOT, creating a new one first when none exists yet (adapted from mkcert's loadCA/newCA). It returns the CA and whether it was newly created.

func (*CA) CertPath

func (c *CA) CertPath() string

CertPath returns the path of the CA certificate (rootCA.pem).

func (*CA) HasKey

func (c *CA) HasKey() bool

HasKey reports whether the CA private key is available. mkcert supports a keyless mode where only the certificate is distributed for installing.

func (*CA) MakeCert

func (c *CA) MakeCert(hosts []string, certFile, keyFile string) error

MakeCert issues a certificate for the given hosts signed by the CA and writes it to certFile/keyFile (adapted from mkcert's makeCert).

Jump to

Keyboard shortcuts

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