ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 8m21s
ci / lint (pull_request) Successful in 11m0s
ci / build (pull_request) Canceled after 8m49s
ci / image (pull_request) Canceled after 0s
Status page servers order certificates on demand. Verified domains were already the only ones they would order for, but nothing bounded how many: an organization switching domains, or many organizations at once, could use up the CA's rate limits that all servers sharing an ACME account depend on, and every handshake or request for a made-up name was passed on to the API. - Before a new order (not a renewal) the server asks the API (POST /agent/v1/certificates). It allows verified domains of pages that server serves, within limits per domain and day, per organization and day, and per ACME account owner and hour (UPTIME_CERTS_*), counted across all instances. - An organization can set a new custom domain at most 10 times a day. - The server remembers names without a page for a minute and passes at most 20 unknown names a second on to the API; pages the sync cached are not affected. Only real pages are recorded as visited. - The page editor explains the three steps: the TXT record, the CNAME record with the platform's status page host as its target (or the organization's own servers), apex domains, and when HTTPS follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// A status page server obtains certificates for custom domains on demand,
|
|
// on the first visit over HTTPS. Before it orders a new one from its CA it
|
|
// asks here: only for a verified domain of a page it serves, and within the
|
|
// limits of UPTIME_CERTS_*. The limits count across all instances and keep
|
|
// one organization, or a flood of handshakes for many names, from using up
|
|
// the CA's rate limits that the other organizations share.
|
|
|
|
type certificateRequest struct {
|
|
Name string `json:"name" binding:"required,max=253"`
|
|
}
|
|
|
|
func (s *Server) agentCertificate(c *gin.Context) {
|
|
var req certificateRequest
|
|
if !bind(c, &req) {
|
|
return
|
|
}
|
|
name := strings.TrimSuffix(strings.ToLower(strings.TrimSpace(req.Name)), ".")
|
|
ctx := c.Request.Context()
|
|
page, ok, err := s.agentServes(ctx, agentOf(c), &name, nil)
|
|
if err != nil {
|
|
internalError(c, err)
|
|
return
|
|
}
|
|
if !ok {
|
|
fail(c, http.StatusNotFound, "not_found")
|
|
return
|
|
}
|
|
lim := s.cfg.Certificates
|
|
if !s.limit(c, "acme:name:"+name, lim.PerNamePerDay, 24*time.Hour) ||
|
|
!s.limit(c, "acme:org:"+page.OrgID.String(), lim.PerOrgPerDay, 24*time.Hour) ||
|
|
!s.limit(c, "acme:owner:"+storageOwner(c), lim.PerOwnerPerHour, time.Hour) {
|
|
s.log.WarnContext(ctx, "certificate order refused by limit", "domain", name, "org", page.OrgID, "agent", agentOf(c).ID)
|
|
return
|
|
}
|
|
s.log.InfoContext(ctx, "certificate order allowed", "domain", name, "org", page.OrgID, "agent", agentOf(c).ID)
|
|
c.Status(http.StatusNoContent)
|
|
}
|