mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
chore: rename domain to certID
This commit is contained in:
parent
0382b80002
commit
f5e6e2d2d9
2 changed files with 17 additions and 17 deletions
|
|
@ -13,40 +13,40 @@ import (
|
|||
"github.com/go-acme/lego/v5/log"
|
||||
)
|
||||
|
||||
func (s *CertificatesStorage) ReadResource(domain string) (*certificate.Resource, error) {
|
||||
raw, err := s.ReadFile(domain, ExtResource)
|
||||
func (s *CertificatesStorage) ReadResource(certID string) (*certificate.Resource, error) {
|
||||
raw, err := s.ReadFile(certID, ExtResource)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load resource for domain %q: %w", domain, err)
|
||||
return nil, fmt.Errorf("unable to load resource for domain %q: %w", certID, err)
|
||||
}
|
||||
|
||||
resource := new(certificate.Resource)
|
||||
if err = json.Unmarshal(raw, resource); err != nil {
|
||||
return nil, fmt.Errorf("unable to unmarshal resource for domain %q: %w", domain, err)
|
||||
return nil, fmt.Errorf("unable to unmarshal resource for domain %q: %w", certID, err)
|
||||
}
|
||||
|
||||
return resource, nil
|
||||
}
|
||||
|
||||
func (s *CertificatesStorage) ReadCertificate(domain string) ([]*x509.Certificate, error) {
|
||||
func (s *CertificatesStorage) ReadCertificate(certID string) ([]*x509.Certificate, error) {
|
||||
// The input may be a bundle or a single certificate.
|
||||
return ReadCertificateFile(s.GetFileName(domain, ExtCert))
|
||||
return ReadCertificateFile(s.GetFileName(certID, ExtCert))
|
||||
}
|
||||
|
||||
func (s *CertificatesStorage) ReadPrivateKey(domain string) (crypto.PrivateKey, error) {
|
||||
privateKey, err := ReadPrivateKeyFile(s.GetFileName(domain, ExtKey))
|
||||
func (s *CertificatesStorage) ReadPrivateKey(certID string) (crypto.PrivateKey, error) {
|
||||
privateKey, err := ReadPrivateKeyFile(s.GetFileName(certID, ExtKey))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while parsing the private key for %q: %w", domain, err)
|
||||
return nil, fmt.Errorf("error while parsing the private key for %q: %w", certID, err)
|
||||
}
|
||||
|
||||
return privateKey, nil
|
||||
}
|
||||
|
||||
func (s *CertificatesStorage) ReadFile(domain, extension string) ([]byte, error) {
|
||||
return os.ReadFile(s.GetFileName(domain, extension))
|
||||
func (s *CertificatesStorage) ReadFile(certID, extension string) ([]byte, error) {
|
||||
return os.ReadFile(s.GetFileName(certID, extension))
|
||||
}
|
||||
|
||||
func (s *CertificatesStorage) ExistsFile(domain, extension string) bool {
|
||||
filePath := s.GetFileName(domain, extension)
|
||||
func (s *CertificatesStorage) ExistsFile(certID, extension string) bool {
|
||||
filePath := s.GetFileName(certID, extension)
|
||||
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
return false
|
||||
|
|
@ -61,6 +61,6 @@ func (s *CertificatesStorage) GetRootPath() string {
|
|||
return s.rootPath
|
||||
}
|
||||
|
||||
func (s *CertificatesStorage) GetFileName(domain, extension string) string {
|
||||
return filepath.Join(s.rootPath, SanitizedName(domain)+extension)
|
||||
func (s *CertificatesStorage) GetFileName(certID, extension string) string {
|
||||
return filepath.Join(s.rootPath, SanitizedName(certID)+extension)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ func (s *CertificatesStorage) Save(certRes *certificate.Resource, opts *SaveOpti
|
|||
}
|
||||
|
||||
// Archive moves the certificate files to the archive folder.
|
||||
func (s *CertificatesStorage) Archive(domain string) error {
|
||||
func (s *CertificatesStorage) Archive(certID string) error {
|
||||
err := CreateNonExistingFolder(s.archivePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not check/create the archive folder %q: %w", s.archivePath, err)
|
||||
}
|
||||
|
||||
baseFilename := filepath.Join(s.rootPath, SanitizedName(domain))
|
||||
baseFilename := filepath.Join(s.rootPath, SanitizedName(certID))
|
||||
|
||||
matches, err := filepath.Glob(baseFilename + ".*")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue