ca intermediate: the renewal hint names the region's HTTPS address, not loopback
CI / agent (push) Successful in 3s
CI / site (push) Successful in 3s
CI / go (push) Successful in 46s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-11-01 19:31:17 +01:00
1 parent 05861bd413
commit 704ac61a27
1 file changed
+25 -1
+25 -1
View File
@@ -30,6 +30,7 @@ import (
"math"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
@@ -374,7 +375,7 @@ func caIntermediateCmd(name string, args []string) error {
return err
}
fmt.Printf("wrote %s.pem and %s.token in %s: intermediate CA %q until %s, may issue for %s\n", name, name, *out, name, res.NotAfter.Format("2006-01-02"), strings.Join(permits, " "))
fmt.Printf("the region renews it: on the host with its key, install deploy/rollcall-intermediate-renew with\n URL=%s NAME=%s TOKEN_FILE=<%s.token there> CERT=<the certificate file> KEY=<the key file>\n", c.base, name, name)
fmt.Printf("the region renews it: on the host with its key, install deploy/rollcall-intermediate-renew with\n URL=%s NAME=%s TOKEN_FILE=<%s.token there> CERT=<the certificate file> KEY=<the key file>\n", regionHTTPS(c.base), name, name)
return nil
}
@@ -399,3 +400,26 @@ func caIntermediatesCmd() error {
}
return tw.Flush()
}
// regionHTTPS: the region's HTTPS address for another host, when the CLI
// talks to it over loopback HTTP on the region itself
func regionHTTPS(base string) string {
if !strings.HasPrefix(base, "http://") {
return base
}
cfg, err := loadConfig(envOr("ROLLCALL_CONFIG", "/etc/rollcall/config.json"))
if err != nil || cfg.TLSListen == "" {
return base
}
u, err := url.Parse(cfg.ServerURL)
if err != nil || u.Hostname() == "" {
return base
}
host := u.Hostname()
if _, port, _ := net.SplitHostPort(cfg.TLSListen); port != "" && port != "443" {
host = net.JoinHostPort(host, port)
} else if strings.Contains(host, ":") {
host = "[" + host + "]"
}
return "https://" + host
}