From 9ad853413f0ef710dfecca07f1068dc03bbb22e1 Mon Sep 17 00:00:00 2001 From: Lewis Cawte Date: Tue, 19 May 2020 13:24:24 +0100 Subject: [PATCH 1/3] Switch import calls to certbot --- README | 2 +- varnish.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index c2fb085..08d4e26 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ To use: 3. Install the module: - pip3 install -e path/to/this/certbot-hitch + pip3 install -e path/to/this/certbot-varnish 4. Ask for a certificate: diff --git a/varnish.py b/varnish.py index 1f6a05c..650bcbb 100644 --- a/varnish.py +++ b/varnish.py @@ -10,9 +10,9 @@ from zope.interface import implementer, provider from acme import challenges -from letsencrypt import errors -from letsencrypt import interfaces -from letsencrypt.plugins import common +from certbot import errors +from certbot import interfaces +from certbot.plugins import common logger = logging.getLogger(__name__) -- 2.39.2 From 2f047981e4873de2c65e84083fb23c79ec8f1126 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 16 Apr 2023 12:59:58 +0200 Subject: [PATCH 2/3] Rename letsencrypt to certbot everywhere. --- varnish.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/varnish.py b/varnish.py index 650bcbb..a1d1448 100644 --- a/varnish.py +++ b/varnish.py @@ -19,10 +19,10 @@ logger = logging.getLogger(__name__) def vcl_recv_line(achall): # Don't bother checking for the right host, we could be coming in through a redirect. - return 'if (req.url == "/%s/%s") { return (synth(999, "Challenge")); } # Added by letsencrypt Varnish plugin for authentication\n' % (achall.URI_ROOT_PATH, achall.chall.encode("token")) + return 'if (req.url == "/%s/%s") { return (synth(999, "Challenge")); } # Added by certbot Varnish plugin for authentication\n' % (achall.URI_ROOT_PATH, achall.chall.encode("token")) def vcl_synth_line(validation): - return 'if (resp.status == 999) { set resp.status = 200; set resp.http.Content-Type = "text/plain"; synthetic("%s"); return (deliver); } # Added by letsencrypt Varnish plugin for authentication\n' % (validation); + return 'if (resp.status == 999) { set resp.status = 200; set resp.http.Content-Type = "text/plain"; synthetic("%s"); return (deliver); } # Added by certbot Varnish plugin for authentication\n' % (validation); @implementer(interfaces.IAuthenticator) @provider(interfaces.IPluginFactory) @@ -66,7 +66,7 @@ class Authenticator(common.Plugin): found_vcl_synth = False new_content = [] for line in content: - if re.search("# Added by letsencrypt Varnish plugin", line): + if re.search("# Added by certbot Varnish plugin", line): # Don't include this line; left by a previous run. continue new_content.append(line) @@ -78,14 +78,14 @@ class Authenticator(common.Plugin): found_vcl_synth = True if not found_vcl_recv: - new_content.append("sub vcl_recv { # Added by letsencrypt Varnish plugin for authentication\n") + new_content.append("sub vcl_recv { # Added by certbot Varnish plugin for authentication\n") new_content.append(vcl_recv_line(achall)) - new_content.append("} # Added by letsencrypt Varnish plugin for authentication\n") + new_content.append("} # Added by certbot Varnish plugin for authentication\n") if not found_vcl_synth: - new_content.append("sub vcl_synth { # Added by letsencrypt Varnish plugin for authentication\n") + new_content.append("sub vcl_synth { # Added by certbot Varnish plugin for authentication\n") new_content.append(vcl_synth_line(validation)) - new_content.append("} # Added by letsencrypt Varnish plugin for authentication\n") + new_content.append("} # Added by certbot Varnish plugin for authentication\n") with open("/etc/varnish/default.vcl", "w") as vcl: vcl.writelines(new_content) -- 2.39.2 From 218440a66eb019e8da97220c66be7d4c81b819c0 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 16 Apr 2023 13:08:16 +0200 Subject: [PATCH 3/3] Small update for certbot in bookworm. --- varnish.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/varnish.py b/varnish.py index a1d1448..15ca475 100644 --- a/varnish.py +++ b/varnish.py @@ -4,7 +4,6 @@ import logging import re import subprocess -import zope.component import zope.interface from zope.interface import implementer, provider @@ -51,6 +50,10 @@ class Authenticator(common.Plugin): responses.append(self._perform_single(achall)) return responses + @classmethod + def add_parser_arguments(cls, add): + pass + def _perform_single(self, achall): # same path for each challenge response would be easier for # users, but will not work if multiple domains point at the -- 2.39.2