pki

package
v0.0.0-...-2dd72ea Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRsaKeyPair

func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey)

func ParseCertificateFromPem

func ParseCertificateFromPem(privPEM []byte) (*x509.Certificate, error)

func ParseRsaPrivateKeyFromPem

func ParseRsaPrivateKeyFromPem(privPEM []byte) (*rsa.PrivateKey, error)

func RsaPrivateKeyToPem

func RsaPrivateKeyToPem(priv *rsa.PrivateKey) []byte

func RsaPublicKeyToPem

func RsaPublicKeyToPem(pub *rsa.PublicKey) []byte

func Setup

func Setup()

Types

type CA

type CA interface {
	Identity
	IssueCertificate(pub interface{}, template *x509.Certificate) (*x509.Certificate, error)
}

func CreateRootCA

func CreateRootCA(cn string) (ca CA, err error)

CreateRootCA creates a root ca

func LoadCA

func LoadCA(filename string) (ca_ CA, err error)

type CAImpl

type CAImpl struct {
	IdentityImpl
}

func (*CAImpl) IssueCertificate

func (ca *CAImpl) IssueCertificate(pub interface{}, template *x509.Certificate) (*x509.Certificate, error)

type Identity

type Identity interface {
	Label() string
	X509Cert() *x509.Certificate
	PublicKey() *rsa.PublicKey
	PrivateKey() *rsa.PrivateKey
	Save(filename string) error
}

CA can be used to issue other certs

func CreateIdentity

func CreateIdentity() (id Identity, err error)

func LoadIdentity

func LoadIdentity(filename string) (id_ Identity, err error)

type IdentityImpl

type IdentityImpl struct {
	// contains filtered or unexported fields
}

func (*IdentityImpl) CreateKeyPair

func (id *IdentityImpl) CreateKeyPair()

func (*IdentityImpl) Label

func (id *IdentityImpl) Label() string

func (*IdentityImpl) Load

func (id *IdentityImpl) Load(filename string) error

func (*IdentityImpl) PrivateKey

func (id *IdentityImpl) PrivateKey() *rsa.PrivateKey

func (*IdentityImpl) PublicKey

func (id *IdentityImpl) PublicKey() *rsa.PublicKey

func (*IdentityImpl) Save

func (id *IdentityImpl) Save(filename string) error

func (*IdentityImpl) X509Cert

func (id *IdentityImpl) X509Cert() *x509.Certificate

type PKIDir

type PKIDir interface {
	GetGenerator() *PkiGenerator
	GetIdentities() (identities []Identity, err error)
}

PKIDir provides access to certificate/private_keys stored in a directory

func NewPKIDir

func NewPKIDir(dir string) (p PKIDir, err error)

type PkiGenerator

type PkiGenerator struct {
	PkiDir string
	CA     CA
}

func (*PkiGenerator) GenerateRoot

func (p *PkiGenerator) GenerateRoot() (err error)

func (*PkiGenerator) GenerateServerCert

func (p *PkiGenerator) GenerateServerCert(name string, dns ...string) (err error)

Jump to

Keyboard shortcuts

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