9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] wildcard in auth/acmed
@ 2024-01-15 14:36 Dave MacFarlane
  2024-01-15 17:02 ` ori
  0 siblings, 1 reply; 4+ messages in thread
From: Dave MacFarlane @ 2024-01-15 14:36 UTC (permalink / raw)
  To: 9front

I was trying to use a Let's Encrypt certificate to host a subdomain,
and the only way I could figure out how to do that was a wildcard certificate
because !/bin/service/tcp443 takes the certificate as an argument before
rc-httpd knows what domain it's for.

A wildcard certificate for *.example.com doesn't cover example.com
with no prefix, so I had to add it as a subject alternative name, but Let's Encrypt
seems to ignore the -t dns and send an http-01 challenge for the non-wildcard
portion and a dns-01 challenge for the wildcard.

I added a "hybrid" type to auth/acmed which determines whether to use dnschallenge
or httpchallenge based on the challenge, but isn't compatible with -o since dnschallenge
and httpchallenge need different formats.

With this, I was able to register a certificate request I created by: 

auth/rsa2csr 'CN=*.example.com,example.com' $certkey>$csr 
auth/acmed -t hybrid $username $acmeuser $csr >$crt

diff 9c2e8e2b13b0d01b7adf88b61af6edfbddd872c1 uncommitted
--- a/sys/src/cmd/auth/acmed.c
+++ b/sys/src/cmd/auth/acmed.c
@@ -633,6 +633,18 @@
 }
 
 static int
+hybridchallenge(char *ty, char *dom, char *tok, int *matched)
+{
+	if (strcmp(ty, "http-01") == 0){
+		challengeout = "/usr/web/.well-known/acme-challenge";
+		return httpchallenge(ty, dom, tok, matched);
+	} else if (strcmp(ty, "dns-01") == 0){
+		challengeout = "/lib/ndb/dnschallenge";
+		return dnschallenge(ty, dom, tok, matched);
+	}
+	return -1;
+}
+static int
 dochallenges(char *dom[], int ndom, JSON *order)
 {
 	JSON *chals, *j, *cl, *id, *wc;
@@ -910,7 +922,13 @@
 	}else if(strcmp(ct, "dns") == 0){
 		challengeout = (co != nil) ? co : "/lib/ndb/dnschallenge";
 		challengefn = dnschallenge;
-	}else {
+	}else if (strcmp(ct, "hybrid") == 0){
+		if (co != nil) {
+			sysfatal("-o not compatible with hybrid challenge");
+		}
+		challengefn = hybridchallenge;
+
+	} else {
 		sysfatal("unknown challenge type '%s'", ct);
 	}

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <2CEDDEA2213DC4D744EAF757A28E45EC@driusan.net>]

end of thread, other threads:[~2024-01-15 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 14:36 [9front] wildcard in auth/acmed Dave MacFarlane
2024-01-15 17:02 ` ori
2024-01-15 17:20   ` Dave MacFarlane
     [not found] <2CEDDEA2213DC4D744EAF757A28E45EC@driusan.net>
2024-01-15 17:38 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).