cert

package
v0.0.0-...-036eace Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchRemoteCertificate

func FetchRemoteCertificate(address string) (*x509.Certificate, error)

FetchRemoteCertificate connects to a server and returns its tls certificate

func FindOrGenerate

func FindOrGenerate(certFile, keyFile string, certType CertificateType) error

FindOrGenerate generates new key and cert if they don't exist

func Fingerprint

func Fingerprint(cert *x509.Certificate) string

Fingerprint returns the fingerprint of a certificate

func FingerprintFromStr

func FingerprintFromStr(c string) (string, error)

FingerprintFromStr returns a fingerprint of a raw certificate parameter

func Read

func Read(path string) (*x509.Certificate, error)

Read reads an x509 certificate from a filepath

func Save

func Save(c *x509.Certificate, fileName string) error

Save writes out a x509 certificate to a file

Types

type Cert

type Cert struct {
	KeyPair tls.Certificate
}

Cert captures TLS certificate information about public/private keypair and an optional CA certificate

func New

func New(keyPair tls.Certificate) *Cert

New returns a new Cert instance

func (*Cert) Fingerprint

func (c *Cert) Fingerprint() (string, error)

Fingerprint returns the fingerprint of the public key.

func (*Cert) PrivateKey

func (c *Cert) PrivateKey() []byte

PrivateKey is a convenience to encode the underlying private key.

func (*Cert) PublicKey

func (c *Cert) PublicKey() []byte

PublicKey is a convenience to encode the underlying public key to ASCII.

type CertificateType

type CertificateType int

CertificateType represents a client or server certificate

const (
	ServerCertificateType CertificateType = 0
	ClientCertificateType CertificateType = 1
)

Types of certificate that can be generated

Jump to

Keyboard shortcuts

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