mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 21:53:48 +03:00
* Allow usage of root CA without a key. Fixes #6290 * Update modules/caddypki/crypto.go --------- Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
parent
b52271061d
commit
c97292b255
1 changed files with 11 additions and 8 deletions
|
@ -78,18 +78,21 @@ func (kp KeyPair) Load() (*x509.Certificate, crypto.Signer, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
keyData, err := os.ReadFile(kp.PrivateKey)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
cert, err := pemDecodeSingleCert(certData)
|
cert, err := pemDecodeSingleCert(certData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
key, err := certmagic.PEMDecodePrivateKey(keyData)
|
|
||||||
if err != nil {
|
var key crypto.Signer
|
||||||
return nil, nil, err
|
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
|
return cert, key, nil
|
||||||
|
|
Loading…
Reference in a new issue