Documentation
¶
Index ¶
- Constants
- func CreateNonExistingFolder(path string) error
- func GetEffectiveAccountID(email, id string) string
- func ReadCSRFile(filename string) (*x509.CertificateRequest, error)
- func ReadCertificateFile(filename string) ([]*x509.Certificate, error)
- func ReadJSONFile[T any](filename string) (*T, error)
- func ReadPrivateKeyFile(filename string) (crypto.Signer, error)
- func SanitizedName(name string) string
- type Account
- type AccountsStorage
- type Archiver
- func (m *Archiver) Accounts(cfg *configuration.Configuration) error
- func (m *Archiver) Certificate(certID string) error
- func (m *Archiver) Certificates(certificates map[string]*configuration.Certificate) error
- func (m *Archiver) ListArchivedAccounts() ([]string, error)
- func (m *Archiver) ListArchivedCertificates() ([]string, error)
- func (m *Archiver) Restore(archivePath string) error
- type Certificate
- type CertificatesStorage
- func (s *CertificatesStorage) ExistsFile(certID, extension string) bool
- func (s *CertificatesStorage) GetFileName(certID, extension string) string
- func (s *CertificatesStorage) GetRootPath() string
- func (s *CertificatesStorage) ReadCertificate(certID string) ([]*x509.Certificate, error)
- func (s *CertificatesStorage) ReadFile(certID, extension string) ([]byte, error)
- func (s *CertificatesStorage) ReadPrivateKey(certID string) (crypto.Signer, error)
- func (s *CertificatesStorage) ReadResource(certID string) (*Certificate, error)
- func (s *CertificatesStorage) Save(certRes *Certificate, opts *SaveOptions) error
- type ConfigurationStorage
- type PrivateKeyNotFound
- type SaveOptions
- type Storage
Constants ¶
const ( OriginConfiguration = "configuration" OriginCommand = "command" OriginMigration = "migration" )
const ( ExtIssuer = ".issuer.crt" ExtCert = ".crt" ExtKey = ".key" ExtPEM = ".pem" ExtPFX = ".pfx" ExtResource = ".json" )
const RootPathWarningMessage = `` /* 329-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CreateNonExistingFolder ¶
func GetEffectiveAccountID ¶
GetEffectiveAccountID returns the effective account ID.
func ReadCSRFile ¶
func ReadCSRFile(filename string) (*x509.CertificateRequest, error)
ReadCSRFile reads a CSR file.
func ReadCertificateFile ¶
func ReadCertificateFile(filename string) ([]*x509.Certificate, error)
ReadCertificateFile reads a certificate file.
func ReadJSONFile ¶
func ReadPrivateKeyFile ¶
ReadPrivateKeyFile reads a private key file.
func SanitizedName ¶
SanitizedName Make sure no funny chars are in the cert names (like wildcards ;)).
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
Email string `json:"email"`
KeyType certcrypto.KeyType `json:"keyType"`
Server string `json:"server"`
Origin string `json:"origin,omitempty"`
Registration *acme.ExtendedAccount `json:"registration"`
NeedsRecovery bool `json:"-"`
// contains filtered or unexported fields
}
Account represents a users local saved credentials.
func NewRecoverableAccount ¶
func (*Account) GetKeyType ¶
func (a *Account) GetKeyType() certcrypto.KeyType
GetKeyType returns the key type of the account.
func (*Account) GetPrivateKey ¶
GetPrivateKey returns the private account key.
func (*Account) GetRegistration ¶
func (a *Account) GetRegistration() *acme.ExtendedAccount
GetRegistration returns the server registration.
func (*Account) SetPrivateKey ¶
SetPrivateKey sets the private account key.
type AccountsStorage ¶
type AccountsStorage struct {
// contains filtered or unexported fields
}
AccountsStorage A storage for account data.
rootPath:
./.lego/accounts/
│ └── root accounts directory
└── "path" option
rootUserPath:
./.lego/accounts/localhost_14000/foo@example.com/
│ │ │ └── accountID
│ │ └── CA server ("server" option)
│ └── root accounts directory
└── "path" option
keyPath:
./.lego/accounts/localhost_14000/foo@example.com/foo@example.com.key
│ │ │ │ └── private key
│ │ │ └── accountID
│ │ └── CA server ("server" option)
│ └── root accounts directory
└── "path" option
accountFilePath:
./.lego/accounts/localhost_14000/foo@example.com/account.json
│ │ │ │ └── account file
│ │ │ └── accountID
│ │ └── CA server ("server" option)
│ └── root accounts directory
└── "path" option
func NewAccountsStorage ¶
func NewAccountsStorage(basePath string) *AccountsStorage
NewAccountsStorage Creates a new AccountsStorage.
func (*AccountsStorage) Get ¶
func (s *AccountsStorage) Get(server string, keyType certcrypto.KeyType, email, accountID string) (*Account, error)
Get gets an account from a file or creates a new one (the files are saved).
func (*AccountsStorage) GetRootPath ¶
func (s *AccountsStorage) GetRootPath() string
GetRootPath returns the root path of the storage of the accounts.
func (*AccountsStorage) Save ¶
func (s *AccountsStorage) Save(account *Account) error
Save saves the account to a file (only the JSON file).
func (*AccountsStorage) SavePrivateKey ¶
func (s *AccountsStorage) SavePrivateKey(account *Account) error
SavePrivateKey saves the private key to a file defined by the account.
type Archiver ¶
type Archiver struct {
// contains filtered or unexported fields
}
Archiver manages the archiving of accounts and certificates.
func (*Archiver) Accounts ¶
func (m *Archiver) Accounts(cfg *configuration.Configuration) error
func (*Archiver) Certificate ¶
func (*Archiver) Certificates ¶
func (m *Archiver) Certificates(certificates map[string]*configuration.Certificate) error
func (*Archiver) ListArchivedAccounts ¶
func (*Archiver) ListArchivedCertificates ¶
type Certificate ¶
type Certificate struct {
*certificate.Resource
Origin string `json:"origin,omitempty"`
}
type CertificatesStorage ¶
type CertificatesStorage struct {
// contains filtered or unexported fields
}
CertificatesStorage a certificates' storage.
rootPath:
./.lego/certificates/
│ └── root certificates directory
└── "path" option
archivePath:
./.lego/archives/
│ └── archived certificates directory
└── "path" option
func NewCertificatesStorage ¶
func NewCertificatesStorage(basePath string) *CertificatesStorage
NewCertificatesStorage create a new certificates storage.
func (*CertificatesStorage) ExistsFile ¶
func (s *CertificatesStorage) ExistsFile(certID, extension string) bool
func (*CertificatesStorage) GetFileName ¶
func (s *CertificatesStorage) GetFileName(certID, extension string) string
func (*CertificatesStorage) GetRootPath ¶
func (s *CertificatesStorage) GetRootPath() string
func (*CertificatesStorage) ReadCertificate ¶
func (s *CertificatesStorage) ReadCertificate(certID string) ([]*x509.Certificate, error)
func (*CertificatesStorage) ReadFile ¶
func (s *CertificatesStorage) ReadFile(certID, extension string) ([]byte, error)
func (*CertificatesStorage) ReadPrivateKey ¶
func (s *CertificatesStorage) ReadPrivateKey(certID string) (crypto.Signer, error)
func (*CertificatesStorage) ReadResource ¶
func (s *CertificatesStorage) ReadResource(certID string) (*Certificate, error)
func (*CertificatesStorage) Save ¶
func (s *CertificatesStorage) Save(certRes *Certificate, opts *SaveOptions) error
Save saves the certificate and related files. - the resource file (JSON) - the certificate file - the private key file (if any) - the issuer certificate file (if any) - the PFX file (if needed) - the PEM file (if needed).
type ConfigurationStorage ¶
type ConfigurationStorage struct {
// contains filtered or unexported fields
}
ConfigurationStorage is a storage for the configuration. The backup is the effective configuration and cannot be used directly.
func NewConfigurationStorage ¶
func NewConfigurationStorage(basePath string) *ConfigurationStorage
NewConfigurationStorage creates a new ConfigurationStorage.
func (*ConfigurationStorage) Backup ¶
func (s *ConfigurationStorage) Backup(cfg *configuration.Configuration) error
Backup saves the configuration to the storage.
func (*ConfigurationStorage) ReadBackup ¶
func (s *ConfigurationStorage) ReadBackup() (*configuration.Configuration, error)
ReadBackup reads the backup configuration.
type PrivateKeyNotFound ¶
type PrivateKeyNotFound struct {
AccountID string
}
func (*PrivateKeyNotFound) Error ¶
func (e *PrivateKeyNotFound) Error() string
type SaveOptions ¶
SaveOptions contains the options for saving a certificate.
type Storage ¶
type Storage struct {
Certificate *CertificatesStorage
Account *AccountsStorage
Archiver *Archiver
Configuration *ConfigurationStorage
}