tls

package
v1.2.115 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCertificateConfiguration = errors.New("tls configuration is invalid")

ErrInvalidCertificateConfiguration is returned when an invalid TLS configuration was found.

View Source
var ErrNoCertificatesConfigured = errors.New("no tls configuration was found")

ErrNoCertificatesConfigured is returned when no TLS configuration was found.

Functions

func CreateSelfSignedCertificate

func CreateSelfSignedCertificate(key interface{}, organizations []string, commonName string) (cert *x509.Certificate, err error)

CreateSelfSignedCertificate creates a self-signed x509 certificate. key is parsed by PublicKey()

func CreateSelfSignedTLSCertificate

func CreateSelfSignedTLSCertificate(key interface{}, organizations []string, commonName string) (*tls.Certificate, error)

CreateSelfSignedTLSCertificate creates a self-signed TLS certificate. key is parsed by PublicKey()

func LoadCertificateAndPool

func LoadCertificateAndPool(
	certPool *x509.CertPool,
	certString, keyString string,
	certFile, keyFile string,
) ([]tls.Certificate, *x509.CertPool, error)

func LoadCertificates

func LoadCertificates(
	certString, keyString string,
	certFile, keyFile string,
	certs ...interface{},
) ([]tls.Certificate, error)

LoadCertificates returns loads a TLS LoadCertificates. certString: Base64 encoded (without padding) string of the TLS certificate (PEM encoded) to be used for HTTP over TLS (HTTPS). Example: certString="-----BEGIN CERTIFICATE-----\nMIIDZTCCAk2gAwIBAgIEV5xOtDANBgkqhkiG9w0BAQ0FADA0MTIwMAYDVQQDDClP..." keyString: Base64 encoded (without padding) string of the private key (PEM encoded) to be used for HTTP over TLS (HTTPS). Example: keyString="-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDg..." certPath: The path to the TLS certificate (pem encoded). Example: certPath=~/cert.pem keyPath: The path to the TLS private key (pem encoded). Example: keyPath=~/key.pem certs: certs of tls.Certificate, *tls.Certificate

func LoadX509CertificatePool

func LoadX509CertificatePool(
	certPool *x509.CertPool,
	certString string,
	certFile string,
	certs ...interface{},
) (*x509.CertPool, error)

LoadX509CertificatePool returns loads a TLS x509.CertPool or update a TLS x509.CertPool if nil. certString: Base64 encoded (without padding) string of the TLS certificate (PEM encoded) to be used for HTTP over TLS (HTTPS). Example: certString="-----BEGIN CERTIFICATE-----\nMIIDZTCCAk2gAwIBAgIEV5xOtDANBgkqhkiG9w0BAQ0FADA0MTIwMAYDVQQDDClP..." certPath: The path to the TLS certificate (pem encoded). Example: certPath=~/cert.pem certs: certs of x509.Certificate, tls.Certificate, *x509.Certificate, *tls.Certificate

func LoadX509Certificates

func LoadX509Certificates(
	certString, keyString string,
	certFile, keyFile string,
) ([]*x509.Certificate, error)

LoadX509Certificates returns loads a TLS LoadCertificates of x509.

func PEMBlockForKey

func PEMBlockForKey(key interface{}) (*pem.Block, error)

PEMBlockForKey returns a PEM-encoded block for key. key is parsed by PublicKey()

func PublicKey

func PublicKey(key interface{}) interface{}

PublicKey returns the public key for a given key or nul.

Types

This section is empty.

Jump to

Keyboard shortcuts

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