summaryrefslogtreecommitdiff
path: root/internal/certbot/certbot.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/certbot/certbot.go')
-rw-r--r--internal/certbot/certbot.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/certbot/certbot.go b/internal/certbot/certbot.go
new file mode 100644
index 0000000..3ce5b41
--- /dev/null
+++ b/internal/certbot/certbot.go
@@ -0,0 +1,26 @@
+// Package certbot issues Let's Encrypt certificates via HTTP-01 webroot
+// validation. Deliberately not the --nginx installer plugin - Skiff, not
+// certbot, owns and regenerates skiff.d/*.conf.
+package certbot
+
+import (
+ "context"
+ "io"
+
+ "skiff/internal/sh"
+)
+
+// Sync issues or expands the certificate named certName to cover exactly
+// domains, via challenge files served from webroot. Idempotent. Assumes
+// `certbot register` has already been run once on the host.
+func Sync(ctx context.Context, out io.Writer, webroot, certName string, domains []string) error {
+ args := []string{
+ "certonly", "--webroot", "-w", webroot,
+ "--cert-name", certName, "--expand",
+ "--non-interactive", "--agree-tos", "--keep-until-expiring",
+ }
+ for _, d := range domains {
+ args = append(args, "-d", d)
+ }
+ return sh.Run(ctx, out, "", "certbot", args...)
+}