Write a missing signing request and give up on a handshake that never returns.

A certificate already on disk still has to be renewable, and a reflector that never finishes TLS must not hold the session past the login timers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-07 14:36:28 +02:00
co-authored by Cursor
parent 3d1a2a1669
commit a405048f23
4 changed files with 120 additions and 16 deletions
+22
View File
@@ -124,6 +124,9 @@ func prepareIdentity(dir, callsign string) (tls.Certificate, bool, string) {
if msg != "" {
return tls.Certificate{}, false, msg
}
if msg := ensureCSR(dir, callsign); msg != "" {
return tls.Certificate{}, false, msg
}
return pair, true, ""
}
if msg := ensureKeyAndCSR(dir, callsign, !keyExists); msg != "" {
@@ -155,6 +158,25 @@ func loadPair(certPath, keyPath, callsign string) (tls.Certificate, string) {
}, ""
}
func ensureCSR(dir, callsign string) string {
csrPath := filepath.Join(dir, csrFileName)
_, err := os.Stat(csrPath)
if err == nil {
return ""
}
if !errors.Is(err, fs.ErrNotExist) {
return "Cannot create " + csrPath
}
key, err := loadKey(filepath.Join(dir, keyFileName))
if err != nil {
return "Cannot create " + csrPath
}
if err := writeCSR(csrPath, key, callsign); err != nil {
return "Cannot create " + csrPath
}
return ""
}
func ensureKeyAndCSR(dir, callsign string, created bool) string {
keyPath := filepath.Join(dir, keyFileName)
var key *rsa.PrivateKey