certificates

package
v0.0.0-...-1e1dff8 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrivateKey

func NewPrivateKey(bitsCount int) (privateKey *rsa.PrivateKey, err error)

NewPrivateKey generates new rsa private key. If bitsCount is less than 4096, then it will be set to 4096

func NewX509Certificate

func NewX509Certificate(
	sn *big.Int,
	subj pkix.Name,
	keyUsage x509.KeyUsage,
	extKeyUsage []x509.ExtKeyUsage) (cert *x509.Certificate)

NewX509Certificate generates x509 cetificate template

Types

type Certificate

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

func (*Certificate) Encode

func (c *Certificate) Encode(
	certPemOut, privKeyPemOut io.ReadWriter) (err error)

Encode certificate with PEM encoding. Puts encoded certificate data into certPemOut and encoded private key into privKeyPemOut

func (*Certificate) IsCA

func (c *Certificate) IsCA() bool

IsCA displays is this certificate is CA

func (*Certificate) IsSigned

func (c *Certificate) IsSigned() bool

func (*Certificate) PublicKey

func (c *Certificate) PublicKey() crypto.PublicKey

PublicKey of the certificate

func (*Certificate) SetBytes

func (c *Certificate) SetBytes(b []byte)

func (*Certificate) SetSigned

func (c *Certificate) SetSigned()

func (*Certificate) Sign

func (c *Certificate) Sign(cert Certificator) (
	err error)

Sign certificate. If cert is nil, then certificate is self signed

func (*Certificate) X509

func (c *Certificate) X509() *x509.Certificate

X509 certificate instance

type CertificationAuthority

type CertificationAuthority struct {
	*Certificate
}

func NewCertificationAuthority

func NewCertificationAuthority() (ca *CertificationAuthority, err error)

NewCertificationAuthority

type Certificator

type Certificator interface {
	PublicKey() crypto.PublicKey
	X509() *x509.Certificate
	SetBytes([]byte)
	Encode(io.ReadWriter, io.ReadWriter) error
	Sign(Certificator) error
	SetSigned()
	IsSigned() bool
	IsCA() bool
}

type TLSCertificate

type TLSCertificate struct {
	*Certificate
}

Jump to

Keyboard shortcuts

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