pki

package
v2.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	RsaPrivateKeyBlockType      = "RSA PRIVATE KEY"
	EcPrivateKeyBlockType       = "EC PRIVATE KEY"
	CertificateBlockType        = "CERTIFICATE"
	CertificateRequestBlockType = "CERTIFICATE REQUEST"

	DefaultDSA     = "P256"
	DefaultRSABits = 2048
)

Variables

This section is empty.

Functions

func EncodeCertPrivateKey

func EncodeCertPrivateKey(priv *PrivateKey) ([]byte, error)

EncodeCertPrivateKey returns PEM-encoded private key data

func EncodeCertificates

func EncodeCertificates(certs ...*x509.Certificate) ([]byte, error)

EncodeCertificates returns the PEM-encoded byte array that represents by the specified certs

func EncodeCertificatesRequest

func EncodeCertificatesRequest(csrs ...*x509.CertificateRequest) ([]byte, error)

EncodeCertificatesRequest returns the PEM-encoded byte array that represents by the specified certs

func ParseCertificates

func ParseCertificates(pemCerts []byte) ([]*x509.Certificate, error)

ParseCertificates takes a PEM encoded x509 certificates byte array and returns A x509 certificate and the block byte array

func SigAlgorithmType

func SigAlgorithmType(priv *PrivateKey) x509.SignatureAlgorithm

Types

type CertPem added in v2.0.10

type CertPem struct {
	Crt []byte
	Key []byte
}

type PKI

type PKI interface {
	// CreateSelfSignedRootCert info: request information for issuing a certificate;
	// durationDay: certificate validity period, in days;
	// generate a self-signed root certificate
	CreateSelfSignedRootCert(info *x509.CertificateRequest, durationDay int) (*CertPem, error)
	// CreateRootCert info: request information for issuing a certificate;
	// durationDay: certificate validity period, in days;
	// parent: root ca certificate, used to issue sub-certificates
	CreateRootCert(info *x509.CertificateRequest, durationDay int, parent *CertPem) (*CertPem, error)
	// CreateSubCert csr: standard CSR request data;
	// durationDay: certificate validity period, in days;
	// parent: root ca certificate, used to issue sub-certificates
	CreateSubCert(csr []byte, durationDay int, parent *CertPem) ([]byte, error)
	// CreateSubCertWithKey info: request information for issuing a certificate;
	// durationDay: certificate validity period, in days;
	// parent: root ca certificate, used to issue sub-certificates
	CreateSubCertWithKey(info *x509.CertificateRequest, durationDay int, parent *CertPem) (*CertPem, error)
}

func NewPKIClient

func NewPKIClient() (PKI, error)

type PrivateKey

type PrivateKey struct {
	Type string
	Key  interface{}
}

PrivateKey wraps a ECC or RSA private key

func GenCertPrivateKey

func GenCertPrivateKey(dsa string, bits int) (*PrivateKey, error)

func ParseCertPrivateKey

func ParseCertPrivateKey(key []byte) (*PrivateKey, error)

ParseCertPrivateKey takes a key PEM byte array and returns a PrivateKey that represents Either an RSA or EC private key.

Jump to

Keyboard shortcuts

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