signing

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCertificatesPEM

func ParseCertificatesPEM(data []byte) ([]*x509.Certificate, error)

ParseCertificatesPEM parses all CERTIFICATE blocks in a PEM bundle.

func ParsePrivateKeyPEM

func ParsePrivateKeyPEM(data []byte, password string) (crypto.Signer, error)

ParsePrivateKeyPEM parses a private key and returns it as crypto.Signer.

Types

type Identity

type Identity struct {
	Signer      crypto.Signer
	Certificate *x509.Certificate
	Chain       []*x509.Certificate
}

Identity binds a private-key signer to its leaf certificate and optional certificate chain. Signer may be backed by software, a smart card, an HSM, or a cloud KMS as long as it implements crypto.Signer.

func NewIdentity

func NewIdentity(signer crypto.Signer, certificate *x509.Certificate, chain ...*x509.Certificate) (*Identity, error)

NewIdentity validates and returns a certificate-backed signer identity.

func NewIdentityPEM

func NewIdentityPEM(certificatePEM, privateKeyPEM []byte, password string) (*Identity, error)

NewIdentityPEM parses a PEM certificate bundle and a PEM private key. PKCS#1 RSA, SEC1 EC, and unencrypted PKCS#8 keys are supported. Legacy PEM encryption is supported when password is supplied.

func (*Identity) CertificateChainDER

func (i *Identity) CertificateChainDER() [][]byte

CertificateChainDER returns the leaf certificate followed by its chain.

func (*Identity) Validate

func (i *Identity) Validate(at time.Time) error

Validate checks that the signer and certificate are present, use the same public key, and, when at is non-zero, that the certificate is time-valid. It intentionally does not establish trust; callers choose their trust roots.

Jump to

Keyboard shortcuts

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