Skip to content

Commit ec85079

Browse files
alexsibtihonnatalia.astashenko
authored andcommitted
Added ability to get Root CA content(/ca-root endpoint)
# Conflicts: # wfe2/wfe.go
1 parent 9564684 commit ec85079

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

wfe2/wfe.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"math/big"
1313
"math/rand/v2"
14+
"io/ioutil"
1415
"net/http"
1516
"net/netip"
1617
"net/url"
@@ -71,7 +72,9 @@ const (
7172
getCertPath = "/get/cert/"
7273
getCertInfoPath = "/get/certinfo/"
7374
buildIDPath = "/build"
74-
healthzPath = "/healthz"
75+
76+
// Plesk
77+
caRootPath = "/ca-root"
7578
)
7679

7780
const (
@@ -428,6 +431,9 @@ func (wfe *WebFrontEndImpl) Handler(stats prometheus.Registerer, oTelHTTPOptions
428431
wfe.HandleFunc(m, buildIDPath, wfe.BuildID, "GET")
429432
wfe.HandleFunc(m, healthzPath, wfe.Healthz, "GET")
430433

434+
// Plesk
435+
wfe.HandleFunc(m, caRootPath, wfe.CARoot, "GET")
436+
431437
// Endpoint for draft-ietf-acme-ari
432438
if features.Get().ServeRenewalInfo {
433439
wfe.HandleFunc(m, renewalInfoPath, wfe.RenewalInfo, "GET", "POST")
@@ -489,6 +495,24 @@ func addRequesterHeader(w http.ResponseWriter, requester int64) {
489495
}
490496
}
491497

498+
// CARoot returns Root CA content
499+
func (wfe *WebFrontEndImpl) CARoot(
500+
ctx context.Context,
501+
logEvent *web.RequestEvent,
502+
response http.ResponseWriter,
503+
request *http.Request) {
504+
filePath := "test/certs/webpki/root-rsa.cert.pem"
505+
caRoot, err := ioutil.ReadFile(filePath)
506+
507+
if err != nil {
508+
prob := probs.ServerInternal(fmt.Sprintf("could not get root ca: %v", err))
509+
wfe.sendError(response, logEvent, prob, nil)
510+
return
511+
}
512+
513+
response.Write(caRoot)
514+
}
515+
492516
// Directory is an HTTP request handler that provides the directory
493517
// object stored in the WFE's DirectoryEndpoints member with paths prefixed
494518
// using the `request.Host` of the HTTP request.

0 commit comments

Comments
 (0)