certio

package
v0.0.0-...-617b798 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package certio provides all operations against certificate.

Package certio provides all operations against certificate.

Package certio provides all operations against certificate.

Index

Constants

View Source
const (
	// PrivateKeyType represents the "RSA Private key" String
	PrivateKeyType = "RSA PRIVATE KEY"
	// CertificateType represents the "Certificate" String
	CertificateType = "CERTIFICATE"
)

Variables

This section is empty.

Functions

func BuildTLSConfig

func BuildTLSConfig(certs CertFilePaths, level string) *tls.Config

func CreateWebCertificate

func CreateWebCertificate(cfg CertificateConfiguration) error

func InitCACertificate

func InitCACertificate(cfg CertificateConfiguration) error

func InitCaContainer

func InitCaContainer()

func IssueCertificate

func IssueCertificate(csrString string) (certPem, caPem string)

func LoadCertificates

func LoadCertificates(c CertFilePaths) ([]byte, tls.Certificate)

func ParseClientCertOU

func ParseClientCertOU(r *http.Request) (string, bool)

Types

type CA

type CA struct {
	Bytes  []byte // CA cert in []byte
	String string //CA Cert in string
	// contains filtered or unexported fields
}

func (CA) CreateTemplate

func (ca CA) CreateTemplate(config settings.CaCertConfig) *x509.Certificate

func (CA) Issue

func (ca CA) Issue(cacert *x509.Certificate, cert *x509.Certificate, pub interface{}, priv interface{}) ([]byte, error)

func (*CA) Load

func (ca *CA) Load(certPath, privkeyPath string) (*x509.Certificate, *rsa.PrivateKey)

Load reads certificate and private key from file specified in certPath and privkeyPath, then returns *x509.Certificate and *rsa.PrivateKey of CA

func (*CA) Read

func (ca *CA) Read(f string) string

Read returns the PEM encoded string in file f

func (CA) Save

func (ca CA) Save(f string, content []byte) error

type CertFilePaths

type CertFilePaths struct {
	CaCertPath     string
	CaPrivKeyPath  string
	WebCertPath    string
	WebPrivKeyPath string
}

CertFilePaths is a collection of certificate related file paths

type CertIO

type CertIO struct {
	Type         string
	ContentBytes []byte
}

type CertificateAuthority

type CertificateAuthority struct {
	Certificate *x509.Certificate
	String      string

	PrivateKey *rsa.PrivateKey
	// contains filtered or unexported fields
}
var CaContainer CertificateAuthority

func (*CertificateAuthority) Cache

func (c *CertificateAuthority) Cache(cert *x509.Certificate, s string, p *rsa.PrivateKey)

Cache saves CA cert and CA private key in memory, and keeps CA cert in PEM encoded string in CertificateAuthority.String

func (CertificateAuthority) IsSet

func (c CertificateAuthority) IsSet() bool

IsSet returns true if certificate and private key are already cached

type CertificateConfiguration

type CertificateConfiguration struct {
	Paths CertFilePaths
	Dir   string
	File  string // the JSON config file
	// contains filtered or unexported fields
}

CertificateConfiguration has all parameters of certio configuration

func (*CertificateConfiguration) Parse

func (config *CertificateConfiguration) Parse()

Parse initializes the parameters from settings.Settings

type CertificateRequest

type CertificateRequest struct {
	Request string `json:"csr"`
	// contains filtered or unexported fields
}

func (CertificateRequest) CreateTemplate

func (c CertificateRequest) CreateTemplate(csr *x509.CertificateRequest) *x509.Certificate

func (CertificateRequest) ParsePEMString

func (c CertificateRequest) ParsePEMString(pem string) (*x509.CertificateRequest, error)

type CertificateResponse

type CertificateResponse struct {
	Certificate string `json:"signed"`
	CA          string `json:"ca"`
}

type CertificateSigningRequest

type CertificateSigningRequest struct {
	Request string `json:"csr"`
}

type PrivateKey

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

func (PrivateKey) Generate

func (p PrivateKey) Generate(keyLen int) (*rsa.PrivateKey, error)

func (PrivateKey) Save

func (p PrivateKey) Save(f string, key *rsa.PrivateKey) error

type WebCertificate

type WebCertificate struct {
	PrivKey PrivateKey
	// contains filtered or unexported fields
}

func (WebCertificate) CreateTemplate

func (c WebCertificate) CreateTemplate(config settings.WebCertConfig) *x509.Certificate

func (WebCertificate) Read

func (c WebCertificate) Read(f string) string

func (WebCertificate) Save

func (c WebCertificate) Save(f string, content []byte) error

Jump to

Keyboard shortcuts

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