diff --git a/docs/wiki/Configuration.md b/docs/wiki/Configuration.md index 26b6633..371c62c 100644 --- a/docs/wiki/Configuration.md +++ b/docs/wiki/Configuration.md @@ -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 | diff --git a/internal/confui/choices.go b/internal/confui/choices.go index 98e664f..37ceb2d 100644 --- a/internal/confui/choices.go +++ b/internal/confui/choices.go @@ -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 diff --git a/internal/confui/choices_test.go b/internal/confui/choices_test.go index 7389077..b166064 100644 --- a/internal/confui/choices_test.go +++ b/internal/confui/choices_test.go @@ -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 diff --git a/internal/confui/fields.go b/internal/confui/fields.go index 7a6922d..d8c0f0a 100644 --- a/internal/confui/fields.go +++ b/internal/confui/fields.go @@ -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) {