From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8GZlBzMJsWUwMQEAe85BDQ:P1 (envelope-from ) for ; Wed, 24 Jan 2024 13:57:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 8GZlBzMJsWUwMQEAe85BDQ (envelope-from ) for ; Wed, 24 Jan 2024 13:57:23 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=gy6tnwk1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=zancanaro.id.au (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706101042; a=rsa-sha256; cv=none; b=ccqrwebZVPiKKhKDXCApkuItgQGMuV0r7kAte/Kc3NMX/CVUFJk51MEnMAZPlUDbqBYD7f Y+tGi1e6zpJWBdSEil73Z3FdIwf3JwDKli+NrrZLgOWUWp/il+49oaPk5XpYymKMZi2PEf 735sTX6BnHfkVQhQaqY0oMKS4xhev6yMOOzWFGDHqDD6vf28YeAHy6Ebh2/7psoIZpbTgM 98J2YdCJdu73hAuJBZRAbc8xox7zCyGpp2RGXIzapEY+QLteeNfk9k8Q1j5zkAuVxmR3ic C4yQgWtCkgMvd9WFVMvyUgfo+eK6WjHqBqbOs96C9yumFH8/Q0hBAWfD0kUNkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=gy6tnwk1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=zancanaro.id.au (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706101042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=LN9qXwAzcxEUkmhW0YClYaFXnmw8TyzmcbZ+a7BNNCg=; b=VraroPX5A5P8dL/qA1dQBYcSHVRniUHw0XFU3CbKZUNSXc5NeJdBByRqbGQrg03OoXN9Y7 sGwjeLwAfMuxvz+GFUER/bmlCt/J7L/SH5kYHYVJbBwP3Ov47NNgZ5W9+CDICJsHgImvPu 7RZW8tgHzKZS+4ojgZAeXk/MWzAqpt9jDrctrvcE3SIJhk0fc192xBd+4DTMSnDvRM1+SJ 8POmJpiPoCss2ITX6w/13S1mKW56THZu2YKAQih2uVCkT6QA2S9Vg6bsD1jzlhdb36XsBN FOwUlNjBQ+QDDT1ILvfkpkMjjB++91Fdb1D+yzRSpxFP/ChYIAIRSrq5o1sreA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AF057B8F5 for ; Wed, 24 Jan 2024 13:57:22 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rScoa-0003ac-OM; Wed, 24 Jan 2024 07:57:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rScoM-0003Rv-6f for bug-guix@gnu.org; Wed, 24 Jan 2024 07:57:00 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rScoL-0001IV-1r for bug-guix@gnu.org; Wed, 24 Jan 2024 07:56:57 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rScoQ-0003ua-9R for bug-guix@gnu.org; Wed, 24 Jan 2024 07:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#46961: [PATCH 1/2] services: certbot: Symlink certificates to /etc/certs Resent-From: Carlo Zancanaro Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 Jan 2024 12:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46961 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 46961@debbugs.gnu.org Received: via spool by 46961-submit@debbugs.gnu.org id=B46961.170610101415003 (code B ref 46961); Wed, 24 Jan 2024 12:57:02 +0000 Received: (at 46961) by debbugs.gnu.org; 24 Jan 2024 12:56:54 +0000 Received: from localhost ([127.0.0.1]:44719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rScoH-0003tu-Sb for submit@debbugs.gnu.org; Wed, 24 Jan 2024 07:56:54 -0500 Received: from voltorb.zancanaro.id.au ([45.77.50.64]:32908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rScoC-0003t2-BY for 46961@debbugs.gnu.org; Wed, 24 Jan 2024 07:56:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=LN9qXwAzcxEUkmh W0YClYaFXnmw8TyzmcbZ+a7BNNCg=; h=references:in-reply-to:date:subject: to:from; d=zancanaro.id.au; b=gy6tnwk1cslZO+6IYgDfhJQBajAog/zSrcHdMFw2 ozu24zYtvmM2ywvDwH0kpKXnm3iw9wFLrQ4VBNgRsg0fiL084vJ6AoWg0X257QxIRPBgGr fg+TdocjbXuKeIT7yGYkg8pesaiprqIZZcSZ4YfxvjpIUQ0J6wA5ak1l0Wo9A= Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id f3f701d4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <46961@debbugs.gnu.org>; Wed, 24 Jan 2024 12:56:26 +0000 (UTC) From: Carlo Zancanaro Date: Wed, 24 Jan 2024 23:18:37 +1100 Message-ID: <10c7ceff68855e611357aca7c1729e312a5410d9.1706098718.git.carlo@zancanaro.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Spam-Score: -4.57 X-Migadu-Queue-Id: AF057B8F5 X-Migadu-Spam-Score: -4.57 X-TUID: YztInlQoNJ7k * gnu/services/certbot.scm (certbot-deploy-hook): New procedure. (certbot-command): Pass new deploy hook to certbot. * doc/guix.texi: Replace "letsencrypt/live" with "certs" throughout. --- doc/guix.texi | 26 +++++++++++++------------- gnu/services/certbot.scm | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a6187690bb..2d43ab9a65 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -43,7 +43,7 @@ Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@* Copyright @copyright{} 2017, 2018, 2020, 2021, 2022 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* -Copyright @copyright{} 2017, 2018 Carlo Zancanaro@* +Copyright @copyright{} 2017, 2018, 2024 Carlo Zancanaro@* Copyright @copyright{} 2017 Thomas Danckaert@* Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* @@ -28117,7 +28117,7 @@ Messaging Services them. See @url{https://prosody.im/doc/letsencrypt}. @example -prosodyctl --root cert import /etc/letsencrypt/live +prosodyctl --root cert import /etc/certs @end example The available configuration parameters follow. Each parameter @@ -28820,8 +28820,8 @@ Telephony Services (welcome-text "Welcome to this Mumble server running on Guix!") (cert-required? #t) ;disallow text password logins - (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem") - (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem"))) + (ssl-cert "/etc/certs/mumble.example.com/fullchain.pem") + (ssl-key "/etc/certs/mumble.example.com/privkey.pem"))) @end lisp After reconfiguring your system, you can manually set the mumble-server @@ -28939,12 +28939,12 @@ Telephony Services File name of the SSL/TLS certificate used for encrypted connections. @lisp -(ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem") +(ssl-cert "/etc/certs/example.com/fullchain.pem") @end lisp @item @code{ssl-key} (default: @code{#f}) Filepath to the ssl private key used for encrypted connections. @lisp -(ssl-key "/etc/letsencrypt/live/example.com/privkey.pem") +(ssl-key "/etc/certs/example.com/privkey.pem") @end lisp @item @code{ssl-dh-params} (default: @code{#f}) @@ -32659,7 +32659,7 @@ Certificate Services Command to be run in a shell once for each successfully issued certificate. For this command, the shell variable @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for -example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new +example, @samp{"/etc/certs/example.com"}) containing the new certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will contain a space-delimited list of renewed certificate domains (for example, @samp{"example.com www.example.com"}. @@ -32668,8 +32668,8 @@ Certificate Services @end deftp For each @code{certificate-configuration}, the certificate is saved to -@code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is -saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}. +@code{/etc/certs/@var{name}/fullchain.pem} and the key is +saved to @code{/etc/certs/@var{name}/privkey.pem}. @node DNS Services @subsection DNS Services @cindex DNS (domain name system) @@ -37355,9 +37355,9 @@ Version Control Services (listen '("443 ssl")) (server-name "git.my-host.org") (ssl-certificate - "/etc/letsencrypt/live/git.my-host.org/fullchain.pem") + "/etc/certs/git.my-host.org/fullchain.pem") (ssl-certificate-key - "/etc/letsencrypt/live/git.my-host.org/privkey.pem") + "/etc/certs/git.my-host.org/privkey.pem") (locations (list (git-http-nginx-location-configuration @@ -38482,9 +38482,9 @@ Version Control Services (nginx-server-block (nginx-server-configuration (ssl-certificate - "/etc/letsencrypt/live/myweb.site/fullchain.pem") + "/etc/certs/myweb.site/fullchain.pem") (ssl-certificate-key - "/etc/letsencrypt/live/myweb.site/privkey.pem") + "/etc/certs/myweb.site/privkey.pem") (listen '("443 ssl http2" "[::]:443 ssl http2")) (locations (list diff --git a/gnu/services/certbot.scm b/gnu/services/certbot.scm index 0c45471659..58e709f8a4 100644 --- a/gnu/services/certbot.scm +++ b/gnu/services/certbot.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2020 Jack Hill ;;; Copyright © 2020 Tobias Geerinckx-Rice ;;; Copyright © 2021 Raghav Gururajan +;;; Copyright © 2024 Carlo Zancanaro ;;; ;;; This file is part of GNU Guix. ;;; @@ -87,6 +88,35 @@ (define-record-type* (body (list "return 301 https://$host$request_uri;")))))) +(define (certbot-deploy-hook name deploy-hook-script) + "Returns a gexp which creates symlinks for privkey.pem and fullchain.pem +from /etc/certs/NAME to /etc/letsenctypt/live/NAME. If DEPLOY-HOOK-SCRIPT is +not #f then it is run after the symlinks have been created." + (program-file + (string-append name "-deploy-hook") + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$(string-append "/etc/certs/" name)) + (chmod #$(string-append "/etc/certs/" name) #o755) + + ;; Create new symlinks + (symlink #$(string-append + "/etc/letsencrypt/live/" name "/privkey.pem") + #$(string-append "/etc/certs/" name "/privkey.pem.new")) + (symlink #$(string-append + "/etc/letsencrypt/live/" name "/fullchain.pem") + #$(string-append "/etc/certs/" name "/fullchain.pem.new")) + + ;; Rename over the top of the old ones, if there are any. + (rename-file #$(string-append "/etc/certs/" name "/privkey.pem.new") + #$(string-append "/etc/certs/" name "/privkey.pem")) + (rename-file #$(string-append "/etc/certs/" name "/fullchain.pem.new") + #$(string-append "/etc/certs/" name "/fullchain.pem")) + #$@(if deploy-hook-script + (list #~(invoke #$deploy-hook-script)) + '()))))) + (define certbot-command (match-lambda (($ package webroot certificates email @@ -118,7 +148,7 @@ (define certbot-command `("--manual-auth-hook" ,authentication-hook) '()) (if cleanup-hook `("--manual-cleanup-hook" ,cleanup-hook) '()) - (if deploy-hook `("--deploy-hook" ,deploy-hook) '())) + (list "--deploy-hook" (certbot-deploy-hook name deploy-hook))) (append (list name certbot "certonly" "-n" "--agree-tos" "--webroot" "-w" webroot @@ -130,7 +160,7 @@ (define certbot-command '("--register-unsafely-without-email")) (if server `("--server" ,server) '()) (if rsa-key-size `("--rsa-key-size" ,rsa-key-size) '()) - (if deploy-hook `("--deploy-hook" ,deploy-hook) '())))))) + (list "--deploy-hook" (certbot-deploy-hook name deploy-hook))))))) certificates))) (program-file "certbot-command" -- 2.41.0