certificate

package
v0.0.0-...-406ac44 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePEMFile

func DecodePEMFile(path string) ([]byte, error)

Procedure:

DecodePEMFile

Purpose:

Convert PEM encoded files into a byte array

Parameters:

Absolute path to the PEM file: path string

Produces:

output []byte
err error

Preconditions:

There is a PEM encoded file at $path
The process has the read rights to the file at $path

Postconditions:

Will error if there is no PEM data in the file and it is not empty
If any errors are generated, they are passed up through err and output will be empty
Output contains the contents of the file at $path decoded from PEM

func GenClientCert

func GenClientCert(name string, parentCert *x509.Certificate, parentKey *rsa.PrivateKey) (PEMPrivKey, PEMCert []byte)

Procedure:

GenClientCert

Purpose:

To generate client certificates and write
their public keys where the server can find them

Parameters:

The name of the client file (sans .crt): name string
The signing parent certificate: parentCert *x509.Certificate
The signing parent private key: parentKey *rsa.PrivateKey

Produces:

Filesystem side effects
The client private key pem encoded: PEMPrivKey []byte
The client cert pem encoded: PEMCert []byte

Preconditions:

A root key has been generated in the file system
common.SettingsDir() is set and won't panic
$name is valid on the filesystem
$name is not "root"

Postconditions:

PEMPrivKey and PEMCert are a valid cert/key pair
PEMCert is signed by parentCert and parentKey
$settingsDir/cert/$name.crt contains the private certificate
$settingsDir/cert/$name.crt contains the private key file

func GenRootCert

func GenRootCert(serverIPs []net.IP)

Generate server certificate and dump to file

func ReadCert

func ReadCert(name string) *x509.Certificate

Procedure:

ReadCert

Purpose:

To decode certificates in $SettingsDir()/cert

Parameters:

The name (sans .crt) of the cert file: name string

Produces:

cert *x509.Certificate

Preconditions:

$SettingsDir()/cert exists
SettingsDir() is set

Postconditions:

Any errors are handled
cert is the certificate PEM encoded in $SettingsDir()/cert/$name.crt

func ReadRsaKey

func ReadRsaKey(name string) *rsa.PrivateKey

Procedure:

ReadRsaPrivKey

Purpose:

To decode RSA private keys in $SettingsDir()/cert

Parameters:

The name (sans .keyflie) of the key file: name string

Produces:

key *rsa.PrivateKey

Preconditions:

$SettingsDir() has been set
$SettingsDir()/cert/$name.keyfile exists and is a readable PEM encoded RSA prvate key

Postconditions:

Errors are handled
key is the private key PEM encoded in $SettingsDir()/cert/$name.keyfile

Types

This section is empty.

Jump to

Keyboard shortcuts

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