Documentation
¶
Index ¶
- Constants
- Variables
- func Base64ToCerts(data []string) ([]*x509.Certificate, error)
- func CertsToBase64(certificates ...*x509.Certificate) []string
- func CertsToDER(certificates ...*x509.Certificate) [][]byte
- func CertsToDERInline(certificates ...*x509.Certificate) []byte
- func CertsToPEM(certificates ...*x509.Certificate) [][]byte
- func CertsToPEMInline(certificates ...*x509.Certificate) []byte
- func DERInlineToCerts(data []byte) ([]*x509.Certificate, error)
- func DERToCerts(data [][]byte) ([]*x509.Certificate, error)
- func DERToKey(data []byte) (crypto.Signer, error)
- func GenerateSerial() (*big.Int, error)
- func GenerateSerialWithStore(ctx context.Context, store SerialStore, maxRetries int) (*big.Int, error)
- func HashECDSA(src *ecdsa.PublicKey) []byte
- func HashED25519(src *ed25519.PublicKey) []byte
- func HashRSA(src *rsa.PublicKey) []byte
- func KeyToDER(key any) ([]byte, error)
- func KeyToPEM(key any) ([]byte, error)
- func Match(chain1, chain2 []*x509.Certificate) error
- func MatchKey(keyPub interface{}, certs []*x509.Certificate) error
- func PEMInlineToCerts(data []byte) ([]*x509.Certificate, error)
- func PEMOrDERToCerts(data [][]byte) ([]*x509.Certificate, error)
- func PEMOrDerToKey(data []byte) (crypto.Signer, error)
- func PEMToCerts(data [][]byte) ([]*x509.Certificate, error)
- func PEMToKey(data []byte) (crypto.Signer, error)
- type CertsProvider
- type Collection
- type CollectionRow
- type CollectionRowBase
- type SerialStore
- type Signer
- type SignerConfig
- type Template
Constants ¶
View Source
const SerialGenerationMaxRetries = 5
Variables ¶
View Source
var ( ErrCertMismatch = errors.New("certificate chains are not semantically equal") ErrCertKeyMismatch = errors.New("public key mismatch") )
View Source
var ErrAlreadyExists = errors.New("serial number already exists")
View Source
var ErrUnsupportedKeyFormat = errors.New("unsupported CertKey format")
View Source
var IPLocalHost = []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback}
Functions ¶
func Base64ToCerts ¶
func Base64ToCerts(data []string) ([]*x509.Certificate, error)
func CertsToBase64 ¶
func CertsToBase64(certificates ...*x509.Certificate) []string
func CertsToDER ¶
func CertsToDER(certificates ...*x509.Certificate) [][]byte
func CertsToDERInline ¶
func CertsToDERInline(certificates ...*x509.Certificate) []byte
func CertsToPEM ¶
func CertsToPEM(certificates ...*x509.Certificate) [][]byte
func CertsToPEMInline ¶
func CertsToPEMInline(certificates ...*x509.Certificate) []byte
func DERInlineToCerts ¶
func DERInlineToCerts(data []byte) ([]*x509.Certificate, error)
func DERToCerts ¶
func DERToCerts(data [][]byte) ([]*x509.Certificate, error)
func GenerateSerial ¶
GenerateSerial generates a random serial number for a certificate.
func GenerateSerialWithStore ¶
func HashED25519 ¶
func Match ¶
func Match(chain1, chain2 []*x509.Certificate) error
Match checks if two certificate chains are semantically equal.
func MatchKey ¶
func MatchKey(keyPub interface{}, certs []*x509.Certificate) error
MatchKey checks if the public key matches the certificate.
func PEMInlineToCerts ¶
func PEMInlineToCerts(data []byte) ([]*x509.Certificate, error)
func PEMOrDERToCerts ¶
func PEMOrDERToCerts(data [][]byte) ([]*x509.Certificate, error)
func PEMToCerts ¶
func PEMToCerts(data [][]byte) ([]*x509.Certificate, error)
Types ¶
type CertsProvider ¶
type CertsProvider interface { // ID is a unique identifier for the data cached by this updater. ID() string // Retrieve returns the updated data. Retrieve() (CollectionRow, error) }
type Collection ¶
type Collection interface { // Get returns the collection of certificates and private CertKey for the given updater. Get(updater CertsProvider) (CollectionRow, error) }
func NewCollection ¶
func NewCollection(cacheDuration time.Duration) Collection
type CollectionRow ¶
type CollectionRow interface { // Certificates returns the underlying certificates chain. Certificates() []*x509.Certificate // Key returns the underlying private CertKey, that corresponds to the public CertKey of the first certificate in // the chain. Key() crypto.Signer // CertificatesPEM returns the PEM encoded collection of certificates. CertificatesPEM() [][]byte // KeyPEM returns the PEM encoded private CertKey. KeyPEM() []byte }
type CollectionRowBase ¶
type CollectionRowBase struct { Certs []*x509.Certificate CertKey crypto.Signer CertsPEM [][]byte CertKeyPEM []byte }
func (*CollectionRowBase) Certificates ¶
func (row *CollectionRowBase) Certificates() []*x509.Certificate
func (*CollectionRowBase) CertificatesPEM ¶
func (row *CollectionRowBase) CertificatesPEM() [][]byte
func (*CollectionRowBase) Fill ¶
func (row *CollectionRowBase) Fill() error
func (*CollectionRowBase) Key ¶
func (row *CollectionRowBase) Key() crypto.Signer
func (*CollectionRowBase) KeyPEM ¶
func (row *CollectionRowBase) KeyPEM() []byte
type SerialStore ¶
type SerialStore interface { // Insert a new serial number in the store. If the serial number is already taken, this must return // ErrAlreadyExists. Insert(ctx context.Context, serial *big.Int) error }
SerialStore keeps track of used serial numbers.
type Signer ¶
type Signer interface { // Sign a CertKey with a template, returning the certificate. // // Pub CertKey is the CertKey of the certificate that will be issued. It must be one of the following supported types: // - *rsa.PublicKey // - *ecdsa.PublicKey // - ed25519.PublicKey // // KeyID must be a random, unique identifier for the certificate. It can be derived from the public CertKey. // Depending on the type of your public CertKey, you can use any of the provided hashers in this package: // - HashRSA // - HashECDSA // - HashED25519 Sign(ctx context.Context, key any, keyID []byte, template *Template) (*x509.Certificate, error) // Rotate updates the issuer chain and the CertKey used to sign the certificates. Rotate(issuers []*x509.Certificate, issuerKey crypto.Signer) }
func NewSigner ¶
func NewSigner(config *SignerConfig) Signer
type SignerConfig ¶
type SignerConfig struct { // SerialStore keeps track of used serial numbers. SerialStore SerialStore // IssuerChain is a list of certificates that will be used to sign the certificate. IssuerChain []*x509.Certificate // IssuerKey is the CertKey that will be used to sign the certificate. It must be the CertKey of the first // certificate in the IssuerChain list. // // The public CertKey of the IssuerKey must be of a supported type: // - *rsa.PublicKey // - *ecdsa.PublicKey // - ed25519.PublicKey IssuerKey crypto.Signer }
type Template ¶
type Template struct { // Exp sets the expiration time of the certificate. // // It is set to 365 days by default. Exp time.Duration // Name is the subject of the certificate. Name pkix.Name // IPAddresses is a list of IP addresses that the certificate is valid for. IPAddresses []net.IP // DNSNames is a list of DNS names that the certificate is valid for. DNSNames []string // LeafOnly revokes the ability of the issued certificate to sign other certificates. LeafOnly bool }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.