@@ -9,15 +9,15 @@ import (
9
9
"crypto/x509/pkix"
10
10
"encoding/asn1"
11
11
"fmt"
12
- "github.com/hlandau/acmeapi"
13
- "github.com/hlandau/acmeapi/acmeendpoints"
14
12
"github.com/hlandau/acmetool/hooks"
15
13
"github.com/hlandau/acmetool/responder"
16
14
"github.com/hlandau/acmetool/solver"
17
15
"github.com/hlandau/acmetool/storage"
18
16
"github.com/hlandau/acmetool/util"
19
17
"github.com/hlandau/xlog"
20
18
"github.com/jmhodges/clock"
19
+ "gopkg.in/hlandau/acmeapi.v2"
20
+ "gopkg.in/hlandau/acmeapi.v2/acmeendpoints"
21
21
"net/http"
22
22
"path/filepath"
23
23
"sort"
@@ -458,7 +458,7 @@ func (r *reconcile) requestCertificateForTarget(t *storage.Target) error {
458
458
return err
459
459
}
460
460
461
- c , err := r .store .ImportCertificate (order .URL )
461
+ c , err := r .store .ImportCertificate (acct , order .URL )
462
462
if err != nil {
463
463
log .Errore (err , "could not import certificate" )
464
464
return err
@@ -590,14 +590,26 @@ func (r *reconcile) generateOrGetKey(trk *storage.TargetRequestKey) (crypto.Priv
590
590
func (r * reconcile ) downloadCertificateAdaptive (c * storage.Certificate ) error {
591
591
log .Debugf ("downloading certificate %v" , c )
592
592
593
- cl , err := r .getGenericClient ()
593
+ if c .Account == nil {
594
+ return fmt .Errorf ("cannot download certificate because it is unknown which account requested it: %v" , c )
595
+ }
596
+
597
+ cl , err := r .getClientForDirectoryURL (c .Account .DirectoryURL )
594
598
if err != nil {
595
599
return err
596
600
}
597
601
602
+ acctAPI := c .Account .ToAPI ()
603
+ if acctAPI .URL == "" {
604
+ err = cl .LocateAccount (context .TODO (), acctAPI )
605
+ if err != nil {
606
+ return err
607
+ }
608
+ }
609
+
598
610
order := & acmeapi.Order {}
599
611
cert := & acmeapi.Certificate {}
600
- isCert , err := cl .LoadOrderOrCertificate (context .TODO (), c .URL , order , cert )
612
+ isCert , err := cl .LoadOrderOrCertificate (context .TODO (), c .URL , acctAPI , order , cert )
601
613
if err != nil {
602
614
return err
603
615
}
@@ -621,7 +633,7 @@ func (r *reconcile) downloadCertificateAdaptive(c *storage.Certificate) error {
621
633
return err
622
634
}
623
635
624
- err = cl .WaitLoadOrder (context .TODO (), order )
636
+ err = cl .WaitLoadOrder (context .TODO (), acctAPI , order )
625
637
if err != nil {
626
638
return err
627
639
}
@@ -640,7 +652,7 @@ func (r *reconcile) downloadCertificateAdaptive(c *storage.Certificate) error {
640
652
URL : order .CertificateURL ,
641
653
}
642
654
643
- err = cl .LoadCertificate (context .TODO (), cert )
655
+ err = cl .LoadCertificate (context .TODO (), acctAPI , cert )
644
656
if err != nil {
645
657
return err
646
658
}
0 commit comments