certificates

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CertificateRSA   = "rsa"
	CertificateEC    = "ec"
	CertificateECDSA = "ecdsa"
)

Variables

This section is empty.

Functions

func GenCertSelfSigned

func GenCertSelfSigned(cn, validTill string) (*certutil.CertBundle, *x509.RevocationList, error)

Func should be used if we are going to issue cert not sign

func GetPrivateKeyTypeAndBitLenght

func GetPrivateKeyTypeAndBitLenght(cert *tls.Certificate) (string, int, error)

func GetRawCertificate

func GetRawCertificate(pemStr string) (*x509.Certificate, error)

GetRawCertificate would return certificate from string

func IsCertificateInRevokedList

func IsCertificateInRevokedList(cert *x509.Certificate, crl *x509.RevocationList) bool

IsCertificateInRevokedList would check if cert is in revoked certificates list

func IsCertificateValid

func IsCertificateValid(pem string, crl *x509.RevocationList) (bool, string, error)

IsCertificateValid would verify if: 1. Certificate is not expired 2. Certificate is not in revokation list It would return true and certificate CN

func LoadCertPair

func LoadCertPair(cert, key []byte) (*tls.Certificate, error)

func SignCSR

func SignCSR(csr []byte, notAfterStr string) (*certutil.ParsedCertBundle, error)

Types

type Certificate

type Certificate struct {
	Serial     string
	CommonName string
	AltNames   []string
	Issuer     string
	Type       string
	ECDSACurve string
	KeyBits    int
	ValidFrom  time.Time
	ValidUntil time.Time
	PrivateKey any
	IssuingCA  string
	PemCert    string
	PemKey     string
	Revoked    bool
}

Certificate is representation of x509.Certificate

func GetCertificateFromPem

func GetCertificateFromPem(cert, key, ca string, crl *x509.RevocationList) (*Certificate, error)

func New

func New(cn, keyType string, keyBits int, options ...Options) (*Certificate, error)

func NewCertificate

func NewCertificate(cert *x509.Certificate, revoked bool) *Certificate

NewCertificate would convert x509 Certificate to Certificate

func (*Certificate) GenerateCSR

func (c *Certificate) GenerateCSR() (string, error)

func (*Certificate) GeneratePrivateKey

func (c *Certificate) GeneratePrivateKey() error

func (*Certificate) PublicKey

func (c *Certificate) PublicKey() any

func (*Certificate) SetParsedPrivateKey

func (c *Certificate) SetParsedPrivateKey(privateKey crypto.Signer, privateKeyType certutil.PrivateKeyType, privateKeyBytes []byte)

type CertificateInvalid

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

func (*CertificateInvalid) Error

func (c *CertificateInvalid) Error() string

type Options

type Options func(*Certificate) error

Options is a type of options for Certificate

func AltNames

func AltNames(altNames []string) Options

AltNames is option to set AltNames

func ECDSACurve

func ECDSACurve(curve string) Options

ECDSACurve is option function to set Certificate curve for ECDSA type cert

func ValidUntil

func ValidUntil(validUntil time.Time) Options

ValidUntil is option to set AltNames

Jump to

Keyboard shortcuts

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