diff --git a/cmd/internal/storage/certificates_reader.go b/cmd/internal/storage/certificates_reader.go index 416d76615..6ba8aec49 100644 --- a/cmd/internal/storage/certificates_reader.go +++ b/cmd/internal/storage/certificates_reader.go @@ -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) } diff --git a/cmd/internal/storage/certificates_writer.go b/cmd/internal/storage/certificates_writer.go index 7ad1fb70e..c801a41f7 100644 --- a/cmd/internal/storage/certificates_writer.go +++ b/cmd/internal/storage/certificates_writer.go @@ -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 {