[go: up one dir, main page]

Skip to content

Commit

Permalink
caddypki: Allow use of root CA without a key. Fixes caddyserver#6290 (c…
Browse files Browse the repository at this point in the history
…addyserver#6298)

* Allow usage of root CA without a key. Fixes caddyserver#6290

* Update modules/caddypki/crypto.go

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
  • Loading branch information
apollo13 and mholt authored May 7, 2024
1 parent b522710 commit c97292b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions modules/caddypki/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c97292b

Please sign in to comment.