pem

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePEMCertificates

func DecodePEMCertificates(crtb []byte) ([]*x509.Certificate, error)

DecodePEMCertificatesChain takes a PEM-encoded x509 certificates byte array and returns all certificates in a slice of x509.Certificate objects.

func DecodePEMCertificatesChain

func DecodePEMCertificatesChain(crtb []byte) ([]*x509.Certificate, error)

DecodePEMCertificatesChain takes a PEM-encoded x509 certificates byte array and returns all certificates in a slice of x509.Certificate objects. Expects certificates to be a chain with leaf certificate to be first in the byte array.

func DecodePEMPrivateKey

func DecodePEMPrivateKey(key []byte) (crypto.Signer, error)

DecodePEMPrivateKey takes a key PEM byte array and returns an object that represents either an RSA or EC private key.

func EncodePrivateKey

func EncodePrivateKey(key any) ([]byte, error)

EncodePrivateKey will encode a private key into PEM format.

func EncodeX509

func EncodeX509(cert *x509.Certificate) ([]byte, error)

EncodeX509 will encode a single *x509.Certificate into PEM format.

func EncodeX509Chain

func EncodeX509Chain(certs []*x509.Certificate) ([]byte, error)

EncodeX509Chain will encode a list of *x509.Certificates into a PEM format chain. Self-signed certificates are not included as per https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.2 Certificates are output in the order they're given; if the input is not ordered as specified in RFC5246 section 7.4.2, the resulting chain might not be valid for use in TLS.

func PublicKeysEqual

func PublicKeysEqual(a, b crypto.PublicKey) (bool, error)

PublicKeysEqual compares two given public keys for equality. The definition of "equality" depends on the type of the public keys. Returns true if the keys are the same, false if they differ or an error if the key type of `a` cannot be determined.

Types

This section is empty.

Jump to

Keyboard shortcuts

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