mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
confui: offer tls_cert = ca where the BBS's CA can sign it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRRorB6EaJ9gFhio2Fa
This commit is contained in:
4 files changed
+18
-7
No files matched your search
@@ -117,8 +117,8 @@ list made from what the file and the machine have, a word beside each:
|
||||
|
||||
| Setting | Offered |
|
||||
|---|---|
|
||||
| a certificate (`tls_cert`, `cert_file`) | `acme` and each `acme:NAME` (with its names), and the certificate files other servers use |
|
||||
| its key (`tls_key`, `key_file`) | the key that goes with the certificate chosen (from another server, or beside it on disk), and the others the file names; not asked for with `acme` |
|
||||
| a certificate (`tls_cert`, `cert_file`) | `acme` and each `acme:NAME` (with its names), `ca` where the BBS's own CA can sign it, and the certificate files other servers use |
|
||||
| its key (`tls_key`, `key_file`) | the key that goes with the certificate chosen (from another server, or beside it on disk), and the others the file names; not asked for with `acme` or `ca` |
|
||||
| an address a server listens on | every address, this machine only, and each of this machine's IPs, at the port it has (or the usual one); one another server is on is marked *taken by* |
|
||||
| `[dns]` `answer` and `*_answer` | the IPs the services listen on, and this machine's |
|
||||
| `[dns]` `primary`, `backup` | this host's servers, and the well-known public ones |
|
||||
|
||||
@@ -226,6 +226,10 @@ func (e *Editor) offerFor(s confedit.Section, key string) (offer, bool) {
|
||||
return o, true
|
||||
}
|
||||
|
||||
// caSigned are the kinds whose certificate the BBS's own CA may sign
|
||||
// (tls_cert = ca, cert_file = ca).
|
||||
var caSigned = map[string]bool{"msn": true, "ymsg": true, "oscar": true, "gemini": true}
|
||||
|
||||
// isCertKey is whether a key names a certificate.
|
||||
func isCertKey(key string) bool { return key == "tls_cert" || key == "cert_file" }
|
||||
|
||||
@@ -272,6 +276,9 @@ func (e *Editor) certOffer(s confedit.Section) offer {
|
||||
d, _ := e.doc.Get(a, "domains")
|
||||
o.add(certs.ACME+":"+a.Name, noteOr(d, "[acme "+a.Name+"]"))
|
||||
}
|
||||
if caSigned[s.Kind] {
|
||||
o.add(certs.CA, "the BBS's own CA signs it for the old names (bbs ca)")
|
||||
}
|
||||
for _, f := range e.files(isCertKey) {
|
||||
o.add(f.value, "as "+f.where)
|
||||
}
|
||||
@@ -284,7 +291,7 @@ func (e *Editor) keyOffer(s confedit.Section, key string) offer {
|
||||
o := offer{open: true}
|
||||
o.add("", "")
|
||||
cert, _ := e.doc.Get(s, certOf(key))
|
||||
if cert != "" && !certs.IsACME(cert) {
|
||||
if cert != "" && !certs.IsACME(cert) && !certs.IsCA(cert) {
|
||||
for _, x := range e.doc.Sections() {
|
||||
for _, ck := range []string{"tls_cert", "cert_file"} {
|
||||
if c, _ := e.doc.Get(x, ck); c == cert {
|
||||
@@ -328,7 +335,7 @@ func (e *Editor) files(keep func(string) bool) []named {
|
||||
continue
|
||||
}
|
||||
v, _ := e.doc.Get(x, k)
|
||||
if v == "" || certs.IsACME(v) || seen[v] {
|
||||
if v == "" || certs.IsACME(v) || certs.IsCA(v) || seen[v] {
|
||||
continue
|
||||
}
|
||||
seen[v] = true
|
||||
|
||||
@@ -62,11 +62,15 @@ func TestCertificateChoices(t *testing.T) {
|
||||
t.Errorf("tn.crt's note %q", n)
|
||||
}
|
||||
noteOf(t, cert, "acme")
|
||||
if slices.Contains(cert.Choices, "ca") {
|
||||
t.Error("irc offered the BBS's CA")
|
||||
}
|
||||
noteOf(t, e.field(sec("msn"), "tls_cert"), "ca")
|
||||
key := e.field(sec("irc"), "tls_key")
|
||||
if len(key.Choices) < 2 || key.Choices[1] != "/etc/bbs/tn.key" || !strings.Contains(key.ChoiceNote(1), "goes with tn.crt") {
|
||||
t.Errorf("irc tls_key: %q %q", key.Choices, key.ChoiceNotes)
|
||||
}
|
||||
if k := e.field(sec("msn"), "tls_key"); k.Default != "not needed with acme" {
|
||||
if k := e.field(sec("msn"), "tls_key"); k.Default != "not needed with acme:mail" {
|
||||
t.Errorf("msn tls_key's default %q", k.Default)
|
||||
}
|
||||
// a file of one's own may still be typed
|
||||
|
||||
@@ -136,8 +136,8 @@ func (e *Editor) field(s confedit.Section, key string, label ...string) item {
|
||||
it.Kind, it.Choices, it.ChoiceNotes, it.Open, it.Multi = view.EntryChoice, o.values, o.notes, o.open, o.multi
|
||||
}
|
||||
if isKeyKey(key) {
|
||||
if c, _ := e.doc.Get(s, certOf(key)); certs.IsACME(c) {
|
||||
it.Default = "not needed with acme"
|
||||
if c, _ := e.doc.Get(s, certOf(key)); certs.IsACME(c) || certs.IsCA(c) {
|
||||
it.Default = "not needed with " + c
|
||||
}
|
||||
}
|
||||
if !confedit.Live(s.Kind, key) {
|
||||
|
||||
Reference in new issue
Block a user