mkcert

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: BSD-3-Clause Imports: 6 Imported by: 2

README

mkcert

Go package for generating certificates with mkcert from github.com/FiloSottile/mkcert.

This library just provides a Go API with which to invoke mkcert. mkcert still needs tobe installed on your system.

Created following https://github.com/FiloSottile/mkcert/issues/45#issuecomment-504611052.

Documentation

Overview

Package mkcert wraps the mkcert CLI (https://github.com/FiloSottile/mkcert) to provide a programmatic means of generating certificates for local services. mkcert output is parsed to find the certificate file locations and whether the CA is trusted.

The CA used and trust stores considered are controlled using the CAROOT and TRUST_STORES envvars mkcert wants. See mkcert -help for more.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoDomains is returned by Gen to indicate no domains were requested.
	// mkcert will not be invoked.
	ErrNoDomains = errors.New("mkcert: no domains specified")
)

Functions

This section is empty.

Types

type Cert

type Cert struct {
	// CARoot is the mkcert directory containing its root CA.
	CARoot string
	// Trusted indicates that the root CA is installed in all of the system
	// trust stores. If not, the user will need to run 'mkcert -install' to
	// ensure their browser trusts the certificate we have generated.
	Trusted bool
	// Domains the certificate covers.
	Domains []string
	// File is the filepath of the certificate file.
	File string
	// KeyFile is the filepath of the private key.
	KeyFile string
}

Cert points to the certificates generated by mkcert, with additional CA and trust info.

func Exec

func Exec(opts ...Opt) (Cert, error)

Exec invokes mkcert to acquire a certificate. A certificate for localhost can be requested using:

mkcert.Exec(Domains("localhost", "::1", "127.0.0.1"))

type Opt

type Opt func(*params)

func CertFile

func CertFile(path string) Opt

CertFile overrides the location of the generated certificate.

func Directory

func Directory(path string) Opt

Directory specifies the working directory of mkcert, and is the path relative to which CertFile and KeyFile are relative to, if specified. When blank, defaults to the current directory.

func Domains

func Domains(domains ...string) Opt

Domains is the list of domains to generate the certificate for.

func KeyFile

func KeyFile(path string) Opt

KeyFile overrides the location of the generated private key.

func RequireTrusted

func RequireTrusted(req bool) Opt

RequireTrusted indicates whether Exec errors if the CA is not trusted.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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