diff options
Diffstat (limited to 'modules/caddypki/crypto.go')
-rw-r--r-- | modules/caddypki/crypto.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/caddypki/crypto.go b/modules/caddypki/crypto.go index 386ce6292..324a4fcfa 100644 --- a/modules/caddypki/crypto.go +++ b/modules/caddypki/crypto.go @@ -78,18 +78,21 @@ func (kp KeyPair) Load() (*x509.Certificate, crypto.Signer, error) { if err != nil { return nil, nil, err } - keyData, err := os.ReadFile(kp.PrivateKey) - if err != nil { - return nil, nil, err - } - cert, err := pemDecodeSingleCert(certData) if err != nil { return nil, nil, err } - key, err := certmagic.PEMDecodePrivateKey(keyData) - if err != nil { - return nil, nil, err + + var key crypto.Signer + if kp.PrivateKey != "" { + keyData, err := os.ReadFile(kp.PrivateKey) + if err != nil { + return nil, nil, err + } + key, err = certmagic.PEMDecodePrivateKey(keyData) + if err != nil { + return nil, nil, err + } } return cert, key, nil |