@@ -76,7 +76,7 @@ func (getter *PfxCertGetter) GetCertificate(ctx context.Context, hello *tls.Clie
76
76
storage := getter .ctx .Storage ()
77
77
78
78
if ! storage .Exists (ctx , getter .CacheCertName ) {
79
- err := getter .GenerateParsedKeys (ctx )
79
+ err := getter .GenerateFullPEM (ctx )
80
80
if err != nil {
81
81
getter .logger .Error ("failed to decode pfx certificate" , zap .Error (err ))
82
82
return nil , err
@@ -180,7 +180,7 @@ func (getter *PfxCertGetter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
180
180
return nil
181
181
}
182
182
183
- func (getter * PfxCertGetter ) GenerateParsedKeys (ctx context.Context ) error {
183
+ func (getter * PfxCertGetter ) GenerateFullPEM (ctx context.Context ) error {
184
184
storage := getter .ctx .Storage ()
185
185
186
186
// Read the PFX file
@@ -204,10 +204,13 @@ func (getter *PfxCertGetter) GenerateParsedKeys(ctx context.Context) error {
204
204
Bytes : x509 .MarshalPKCS1PrivateKey (privateKey .(* rsa.PrivateKey )),
205
205
})... )
206
206
207
- // Combine leaf and intermediates from PFX and fetch the full chain automatically
208
- chain , err := getCertificateChain (append ([]* x509.Certificate {certificate }, caCerts ... ))
209
- if err != nil {
210
- return err
207
+ // Combine leaf and intermediates from PFX
208
+ chain := append ([]* x509.Certificate {certificate }, caCerts ... )
209
+ if * getter .FetchFullChain {
210
+ // Fetch the full chain automatically is certificates missing
211
+ if chain , err = getCertificateChain (chain ); err != nil {
212
+ return err
213
+ }
211
214
}
212
215
213
216
// Append all certificates
0 commit comments