@@ -627,29 +627,35 @@ func (cfg *Config) renewDynamicCertificate(ctx context.Context, hello *tls.Clien
627
627
}
628
628
629
629
if log != nil {
630
- log . Info ( "attempting certificate renewal" ,
630
+ log = log . With (
631
631
zap .String ("server_name" , name ),
632
632
zap .Strings ("subjects" , currentCert .Names ),
633
633
zap .Time ("expiration" , expiresAt (currentCert .Leaf )),
634
634
zap .Duration ("remaining" , timeLeft ),
635
- zap .Bool ("revoked" , revoked ))
636
- }
637
-
638
- // Make sure a certificate for this name should be obtained on-demand
639
- err := cfg .checkIfCertShouldBeObtained (name )
640
- if err != nil {
641
- // if not, remove from cache (it will be deleted from storage later)
642
- cfg .certCache .mu .Lock ()
643
- cfg .certCache .removeCertificate (currentCert )
644
- cfg .certCache .mu .Unlock ()
645
- unblockWaiters ()
646
- return Certificate {}, err
635
+ zap .Bool ("revoked" , revoked ),
636
+ )
647
637
}
648
638
649
639
// Renew and reload the certificate
650
640
renewAndReload := func (ctx context.Context , cancel context.CancelFunc ) (Certificate , error ) {
651
641
defer cancel ()
652
642
643
+ if log != nil {
644
+ log .Info ("attempting certificate renewal" )
645
+ }
646
+
647
+ // Make sure a certificate for this name should be obtained on-demand
648
+ err := cfg .checkIfCertShouldBeObtained (name )
649
+ if err != nil {
650
+ // if not, remove from cache (it will be deleted from storage later)
651
+ cfg .certCache .mu .Lock ()
652
+ cfg .certCache .removeCertificate (currentCert )
653
+ cfg .certCache .mu .Unlock ()
654
+ unblockWaiters ()
655
+ log .Error ("certificate should not be obtained" , zap .Error (err ))
656
+ return Certificate {}, err
657
+ }
658
+
653
659
// otherwise, renew with issuer, etc.
654
660
var newCert Certificate
655
661
if revoked {
@@ -679,10 +685,7 @@ func (cfg *Config) renewDynamicCertificate(ctx context.Context, hello *tls.Clien
679
685
680
686
if err != nil {
681
687
if log != nil {
682
- log .Error ("renewing and reloading certificate" ,
683
- zap .String ("server_name" , name ),
684
- zap .Error (err ),
685
- zap .Bool ("forced" , revoked ))
688
+ log .Error ("renewing and reloading certificate" , zap .Error (err ))
686
689
}
687
690
return newCert , err
688
691
}
0 commit comments