cert

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cert package provides basic utility functions to generate x509 certificates

Index

Constants

View Source
const (
	// DefaultLifetime configures certificate validity.
	DefaultLifetime = (24 * 365) * time.Hour

	// DefaultClockSkewAllowance indicates the maximum allowed difference in clocks
	// in the network.
	DefaultClockSkewAllowance = 10 * time.Second
)

Variables

View Source
var (
	// ErrCertEncodeCode represents the error code which is
	// generated when an encode operation fails
	ErrCertEncodeCode = "1101"
	// ErrEncodeCertificatesPEMCode represents the error code which is
	// generated when an certificate PEM encode operations fails
	ErrEncodeCertificatesPEMCode = "1102"
	// ErrEncodePrivateKeyPEMCode represents the error code which is
	// generated when an private key PEM encode operations fails
	ErrEncodePrivateKeyPEMCode = "1103"
	// ErrCreateRootCACode represents the error code which is
	// generated when root CA generation fails
	ErrCreateRootCACode = "1104"
	// ErrGeneratePKCode represents the error code which is
	// generated when private key generation fails
	ErrGeneratePKCode = "1105"
	// ErrGenerateDefaultRootCACode represents the error code which is
	// generated when defaut root CA generation fails
	ErrGenerateDefaultRootCACode = "1106"
)

Functions

func CreateRootCA

func CreateRootCA(name string, key *ecdsa.PrivateKey, validFrom *time.Time) (*x509.Certificate, error)

CreateRootCA generates root CA

func EncodeCertificatesPEM

func EncodeCertificatesPEM(crts ...*x509.Certificate) ([]byte, error)

EncodeCertificatesPEM encodes the collection of provided certificates as a text blob of PEM-encoded certificates.

func EncodePrivateKeyPEM

func EncodePrivateKeyPEM(k *ecdsa.PrivateKey) ([]byte, error)

EncodePrivateKeyPEM encodes the provided key as PEM-encoded text

func ErrCertEncode

func ErrCertEncode(err error) error

ErrCertEncode is the error for encode failure

func ErrCreateRootCA

func ErrCreateRootCA(err error) error

ErrCreateRootCA is the error for root ca generation failure

func ErrEncodeCertificatesPEM

func ErrEncodeCertificatesPEM(err error) error

ErrEncodeCertificatesPEM is the error for certificate encode failure

func ErrEncodePrivateKeyPEM

func ErrEncodePrivateKeyPEM(err error) error

ErrEncodePrivateKeyPEM is the error for private key PEM encode failure

func ErrGenerateDefaultRootCA

func ErrGenerateDefaultRootCA(err error) error

ErrGenerateDefaultRootCA is the error for default root ca generation failure

func ErrGeneratePK

func ErrGeneratePK(err error) error

ErrGeneratePK is the error for private key generation failure

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

GenerateKey creates a new P-256 ECDSA private key from the default random source.

func GenerateRootCAWithDefaults

func GenerateRootCAWithDefaults(name string) (*x509.Certificate, *ecdsa.PrivateKey, error)

GenerateRootCAWithDefaults generates a new root CA with default settings.

func GetDefaultX509Cert

func GetDefaultX509Cert(serialNumber uint64, k *ecdsa.PublicKey, validFrom *time.Time) *x509.Certificate

GetDefaultX509Cert returns x509 cert with some defaults

func GetWindow

func GetWindow(t time.Time, lifetime, clockSkewAllowance time.Duration) (time.Time, time.Time)

GetWindow returns cert validity window based on the arguments given

Types

This section is empty.

Jump to

Keyboard shortcuts

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