cert

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PEMBlockRSAPrivateKey       = "RSA PRIVATE KEY"
	PEMBlockECPrivateKey        = "EC PRIVATE KEY"
	PEMBlockEncryptedPrivateKey = "ENCRYPTED PRIVATE KEY"
	PEMBlockPrivateKey          = "PRIVATE KEY"
	PEMBlockCertificate         = "CERTIFICATE"
)

Variables

This section is empty.

Functions

func CreateDevPEM added in v0.8.0

func CreateDevPEM(dns ...string) ([]byte, any, error)

CreateDevPEM creates a self-signed certificate for development. Returns certificate DER bytes and private key.

func DERBytesToPEMBlocks

func DERBytesToPEMBlocks(der []byte, priv any, opt ...Option) ([]byte, []byte, error)

DERBytesToPEMBlocks converts certificate DER bytes and optional private key to PEM blocks. Returns certificate PEM block and private key PEM block.

func DevPEMFile added in v0.8.0

func DevPEMFile(name string, dns ...string) ([]byte, []byte, error)

DevPEMFile loads or generates new TLS certificate for development.

func LoadPEMFromFile added in v0.8.0

func LoadPEMFromFile(path string, opt ...Option) ([]byte, []byte, error)

LoadPEMFromFile loads a PEM-encoded certificate and private key from the specified file.

func LoadPEMFromReader added in v0.8.0

func LoadPEMFromReader(r io.Reader, opt ...Option) ([]byte, []byte, error)

LoadPEMFromReader loads a PEM-encoded certificate and private key from the io.Reader.

func LoadTLSCertificate

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

LoadTLSCertificate parses a public/private key pair from a pair of PEM encoded data.

func ParseTLSCertificateFromFile added in v0.8.0

func ParseTLSCertificateFromFile(path string, opt ...Option) (*tls.Certificate, error)

ParseTLSCertificateFromReader parses a public/private key pair from a PEM encoded file.

func ParseTLSCertificateFromReader added in v0.8.0

func ParseTLSCertificateFromReader(r io.Reader, opt ...Option) (*tls.Certificate, error)

ParseTLSCertificateFromReader parses a public/private key pair from a PEM encoded data io.Reader source.

Types

type Option added in v0.14.0

type Option interface {
	// contains filtered or unexported methods
}

Option for loading a certificates.

type Password added in v0.14.0

type Password []byte

Password to decrypt the private key.

Jump to

Keyboard shortcuts

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