zcert – zgo.at/zcert Index | Files | Directories

package zcert

import "zgo.at/zcert"

Index

Types

type CARoot

type CARoot struct {
	Verbose bool // Print verbose output to stderr.
	// contains filtered or unexported fields
}

CARoot is a root certificate that's used to sign certificates with.

func New

func New() (ca CARoot, created bool, err error)

New creates a new instance of CARoot. It will load an existing root certificate if it exists, or creates a new one if it doesn't.

func (CARoot) Certificate

func (ca CARoot) Certificate() *x509.Certificate

Certificate gets the loaded root certificate; may return nil if Load() isn't called yet.

func (*CARoot) Create

func (ca *CARoot) Create() error

Create a new root certificate; this will return an error if a root CA already exist.

func (CARoot) Delete

func (ca CARoot) Delete() error

Delete the root certificate.

func (CARoot) Exists

func (ca CARoot) Exists() bool

Exists reports if the root certificate exits.

func (CARoot) Install

func (ca CARoot) Install() error

Install the root certificate to all truststores we can find.

func (*CARoot) Load

func (ca *CARoot) Load() error

Load the root certificate from disk.

func (CARoot) MakeCert

func (ca CARoot) MakeCert(out io.Writer, clientCert bool, hosts ...string) error

MakeCert creates a new certificate signed with the root certificate and writes the PEM-encoded data to out.

func (CARoot) MakeTLSCert

func (ca CARoot) MakeTLSCert(clientCert bool, hosts ...string) (*tls.Certificate, error)

MakeTLS creates a new TLS certificate signed with the root certificate.

func (CARoot) StorePath

func (CARoot) StorePath() (string, string)

StorePaths gets the full path name to the root certificate. Returns certificate and key.

func (CARoot) TLSConfig

func (ca CARoot) TLSConfig() *tls.Config

TLSConfig returns a new tls.Config which creates certificates for any hostname.

func (CARoot) Uninstall

func (ca CARoot) Uninstall() error

Uninstall the root certificate from all truststores we can find.

type Group

type Group struct {
	// Maximum number of errors; calls to Append() won't do anything if the number of errors is larger than this.
	MaxSize int
	// contains filtered or unexported fields
}

Group multiple errors.

func NewGroup

func NewGroup(maxSize int) *Group

NewGroup create a new Group instance. It will record a maximum of maxSize errors. Set to 0 for no limit.

func (*Group) Append

func (g *Group) Append(err error) bool

Append a new error to the list; this is thread-safe.

It won't do anything if the error is nil, in which case it will return false. This makes appending errors in a loop slightly nicer:

for {
    err := do()
    if errors.Append(err) {
        continue
    }
}

func (Group) Error

func (g Group) Error() string

func (*Group) ErrorOrNil

func (g *Group) ErrorOrNil() error

ErrorOrNil returns itself if there are errors, or nil otherwise.

It avoids an if-check at the end:

return errs.ErrorOrNil()

func (Group) Len

func (g Group) Len() int

Len returns the number of errors.

Source Files

errors.go zcert.go

Directories

PathSynopsis
cmd
cmd/serve
cmd/zcert
truststore
Version
v0.0.0-20211017212315-ace8b819ce86 (latest)
Published
Oct 17, 2021
Platform
linux/amd64
Imports
27 packages
Last checked
1 week ago

Tools for package owners.