Help us shape the future of Go! Take the 2026 Go Developer Survey

certs

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// CertificateHeader is the first line of a certificate file
	CertificateHeader = "-----BEGIN CERTIFICATE-----"
	// PrivateKeyHeader is the first line of a private key file
	PrivateKeyHeader = "-----BEGIN RSA PRIVATE KEY-----"
)

Variables

This section is empty.

Functions

func LoadCertificate added in v1.1.2

func LoadCertificate(certificate string) ([]byte, error)

func LoadPrivateKey added in v1.1.2

func LoadPrivateKey(privateKey string) ([]byte, error)

Types

type Certificate

type Certificate struct {
	X509       *x509.Certificate
	PrivateKey *rsa.PrivateKey
	Chain      []*Certificate
	// contains filtered or unexported fields
}

Certificate is a X509 certifcate / private key pair

func DecodeCertificate

func DecodeCertificate(cert []byte, privateKey []byte) (*Certificate, error)

DecodeCertificate decodes a certificate / private key pair and returns a Certificate

func DecryptCertificate

func DecryptCertificate(cert []byte, privateKey []byte, password []byte) (*Certificate, error)

DecryptCertificate decrypts a certificate / private key pair and returns a Certificate

func (*Certificate) AsTLSConfig added in v1.3.6

func (c *Certificate) AsTLSConfig() *tls.Config

func (*Certificate) AsTLSSecret

func (c *Certificate) AsTLSSecret() map[string][]byte

func (Certificate) EncodedCertificate

func (c Certificate) EncodedCertificate() []byte

EncodedCertificate returns PEM-endcoded certificate data.

func (Certificate) EncodedPrivateKey

func (c Certificate) EncodedPrivateKey() []byte

EncodedPrivateKey returns PEM-encoded private key data.

func (Certificate) EncodedPublicKey

func (c Certificate) EncodedPublicKey() []byte

EncodedPublicKey returns PEM-encoded public key data.

func (Certificate) GetHash

func (c Certificate) GetHash() (string, error)

GetHash returns the encoded sha256 hash for the certificate

func (Certificate) GetPublicChain

func (c Certificate) GetPublicChain() []*Certificate

func (*Certificate) IsLazyLoaded added in v1.3.6

func (c *Certificate) IsLazyLoaded() bool

func (*Certificate) Load added in v1.3.6

func (c *Certificate) Load() (*Certificate, error)

func (Certificate) MarshalYAML added in v1.1.4

func (c Certificate) MarshalYAML() (interface{}, error)

func (*Certificate) Sign

func (ca *Certificate) Sign(cert *x509.Certificate, expiry time.Duration) (*x509.Certificate, error)

func (*Certificate) SignCertificate

func (ca *Certificate) SignCertificate(cert *Certificate, expiryYears int) (*Certificate, error)

func (*Certificate) UnmarshalYAML added in v1.1.2

func (c *Certificate) UnmarshalYAML(unmarshal func(interface{}) error) error

type CertificateAuthority

type CertificateAuthority interface {
	SignCertificate(cert *Certificate, expiryYears int) (*Certificate, error)
	Sign(cert *x509.Certificate, expiry time.Duration) (*x509.Certificate, error)
	GetPublicChain() []*Certificate
}

type CertificateBuilder

type CertificateBuilder struct {
	*Certificate
}

func NewCertificateBuilder

func NewCertificateBuilder(commonName string) *CertificateBuilder

func (*CertificateBuilder) AltName

func (b *CertificateBuilder) AltName(names ...string) *CertificateBuilder

func (*CertificateBuilder) CA

func (*CertificateBuilder) Client

func (*CertificateBuilder) Organization

func (b *CertificateBuilder) Organization(org string) *CertificateBuilder

func (*CertificateBuilder) OrganizationUnit

func (b *CertificateBuilder) OrganizationUnit(ou string) *CertificateBuilder

func (*CertificateBuilder) Server

func (*CertificateBuilder) ValidYears

func (b *CertificateBuilder) ValidYears(years int) *CertificateBuilder

type CertificateMarshaller added in v1.1.2

type CertificateMarshaller struct {
	CertFile       string `yaml:"cert,omitempty"`
	PrivateKeyFile string `yaml:"privateKey,omitempty"`
	Password       string `yaml:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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