### GenerateOpts Configuration Source: https://pkg.go.dev/github.com/google/certtostore Parameters used to configure private key generation. ```go type GenerateOpts struct { // Algorithm to be used, either RSA or EC. Algorithm Algorithm // Size is used to specify the bit size of the RSA key or curve for EC keys. Size int } ``` -------------------------------- ### FileStorage Implementation Source: https://pkg.go.dev/github.com/google/certtostore Defines the FileStorage struct and its associated methods for disk-based certificate management. ```go type FileStorage struct { // contains filtered or unexported fields } ``` ```go func NewFileStorage(basepath string) *FileStorage ``` ```go func (f FileStorage) Cert() (*x509.Certificate, error) ``` ```go func (f FileStorage) CertificateChain() ([][]*x509.Certificate, error) ``` ```go func (f FileStorage) Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) ([]byte, error) ``` ```go func (f *FileStorage) Generate(opts GenerateOpts) (crypto.Signer, error) ``` ```go func (f FileStorage) Intermediate() (*x509.Certificate, error) ``` ```go func (f FileStorage) Key() (Credential, error) ``` ```go func (f FileStorage) Public() crypto.PublicKey ``` ```go func (f FileStorage) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) ``` ```go func (f *FileStorage) Store(cert *x509.Certificate, intermediate *x509.Certificate) error ``` -------------------------------- ### Algorithm.Tox509 Method Source: https://pkg.go.dev/github.com/google/certtostore Converts the Algorithm type to an x509.PublicKeyAlgorithm. ```go func (a Algorithm) Tox509() x509.PublicKeyAlgorithm ``` -------------------------------- ### Define Algorithm Types Source: https://pkg.go.dev/github.com/google/certtostore Defines the supported asymmetric algorithms for credentials. ```go type Algorithm string ``` ```go const ( EC Algorithm = "EC" RSA Algorithm = "RSA" ) ``` -------------------------------- ### Credential Interface Source: https://pkg.go.dev/github.com/google/certtostore Provides access to a certificate, implementing crypto.Signer and crypto.Decrypter. ```go type Credential interface { // Public returns the public key corresponding to the leaf certificate. Public() crypto.PublicKey // Sign signs digest with the private key. Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error) // Decrypt decrypts msg. Returns an error if not implemented. Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error) } ``` -------------------------------- ### CertStorage Interface Source: https://pkg.go.dev/github.com/google/certtostore Defines the interface for backend certificate storage operations. ```go type CertStorage interface { // Cert returns the current X509 certificate or nil if no certificate is installed. Cert() (*x509.Certificate, error) // Intermediate returns the current intermediate X509 certificate or nil if no certificate is installed. Intermediate() (*x509.Certificate, error) // CertificateChain returns the leaf and subsequent certificates. CertificateChain() ([][]*x509.Certificate, error) // Generate generates a new private key in the storage and returns a signer that can be used // to perform signatures with the new key and read the public portion of the key. CertStorage // implementations should strive to ensure a Generate call doesn't actually destroy any current // key or cert material and to only install the new key for clients once Store is called. Generate(opts GenerateOpts) (crypto.Signer, error) // Store finishes the cert installation started by the last Generate call with the given cert and // intermediate. Store(cert *x509.Certificate, intermediate *x509.Certificate) error // Key returns the certificate as a Credential (crypto.Signer and crypto.Decrypter). Key() (Credential, error) } ``` -------------------------------- ### Decode PEM to x509 Certificate Source: https://pkg.go.dev/github.com/google/certtostore Converts a raw PEM-encoded byte slice into an x509.Certificate structure. ```go func PEMToX509(b []byte) (*x509.Certificate, error) ``` -------------------------------- ### func PEMToX509 Source: https://pkg.go.dev/github.com/google/certtostore Decodes a raw PEM certificate into an x509.Certificate structure. ```APIDOC ## func PEMToX509(b []byte) (*x509.Certificate, error) ### Description PEMToX509 takes a raw PEM certificate and decodes it to an x509.Certificate. ### Parameters - **b** ([]byte) - Required - The raw PEM encoded certificate data. ### Returns - **(*x509.Certificate, error)** - Returns the decoded certificate or an error if decoding fails. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.