Skip to content

Commit fb2d9bf

Browse files
committed
Write CSR PEM to cert_obtained events
Close caddyserver/caddy#5999
1 parent 167015d commit fb2d9bf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

config.go

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"crypto/x509/pkix"
2525
"encoding/asn1"
2626
"encoding/json"
27+
"encoding/pem"
2728
"errors"
2829
"fmt"
2930
"io/fs"
@@ -664,6 +665,10 @@ func (cfg *Config) obtainCert(ctx context.Context, name string, interactive bool
664665
"private_key_path": StorageKeys.SitePrivateKey(issuerKey, certKey),
665666
"certificate_path": StorageKeys.SiteCert(issuerKey, certKey),
666667
"metadata_path": StorageKeys.SiteMeta(issuerKey, certKey),
668+
"csr_pem": pem.EncodeToMemory(&pem.Block{
669+
Type: "CERTIFICATE REQUEST",
670+
Bytes: csr.Raw,
671+
}),
667672
})
668673

669674
return nil
@@ -924,6 +929,10 @@ func (cfg *Config) renewCert(ctx context.Context, name string, force, interactiv
924929
"private_key_path": StorageKeys.SitePrivateKey(issuerKey, certKey),
925930
"certificate_path": StorageKeys.SiteCert(issuerKey, certKey),
926931
"metadata_path": StorageKeys.SiteMeta(issuerKey, certKey),
932+
"csr_pem": pem.EncodeToMemory(&pem.Block{
933+
Type: "CERTIFICATE REQUEST",
934+
Bytes: csr.Raw,
935+
}),
927936
})
928937

929938
return nil

0 commit comments

Comments
 (0)