obynio / certbot-plugin-gandi

Certbot plugin for authentication using Gandi LiveDNS
https://pypi.org/project/certbot-plugin-gandi/
MIT License
194 stars 27 forks source link

Plugin broke since certbot 2.x #42

Closed JulienPalard closed 1 year ago

JulienPalard commented 1 year ago

see: https://github.com/certbot/certbot/issues/9485

HLFH commented 1 year ago

Fixed by: https://github.com/obynio/certbot-plugin-gandi/pull/41. You may close. We only need to have it merged.

obynio commented 1 year ago

Fix released in 1.4.2. I hope it will work.

JulienPalard commented 1 year ago

Just tried 1.4.2:

with:

acme                 1.31.0
certbot              1.31.0
certbot-plugin-gandi 1.4.2

it works, but with:

acme                 2.0.0
certbot              2.0.0
certbot-plugin-gandi 1.4.2

it does not:

$ certbot renew --dry-run
An unexpected error occurred:
AttributeError: module 'certbot.interfaces' has no attribute 'IAuthenticator'

TB from the logs:

2022-12-05 11:58:18,034:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
  File "/root/./certbot-venv/bin/certbot", line 8, in <module>
    sys.exit(main())
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot/main.py", line 19, in main
    return internal_main.main(cli_args)
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot/_internal/main.py", line 1707, in main
    plugins = plugins_disco.PluginsRegistry.find_all()
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot/_internal/plugins/disco.py", line 208, in find_all
    cls._load_entry_point(entry_point, plugins)
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot/_internal/plugins/disco.py", line 215, in _load_entry_point
    plugin_ep = PluginEntryPoint(entry_point)
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot/_internal/plugins/disco.py", line 56, in __init__
    self.plugin_cls: Type[interfaces.Plugin] = entry_point.load()
  File "/root/certbot-venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2471, in load
    return self.resolve()
  File "/root/certbot-venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2477, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot_plugin_gandi/main.py", line 24, in <module>
    class Authenticator(dns_common.DNSAuthenticator):
  File "/root/certbot-venv/lib/python3.9/site-packages/certbot_plugin_gandi/main.py", line 19, in register_authenticator
    zope.interface.implementer(interfaces.IAuthenticator)(cls)
AttributeError: module 'certbot.interfaces' has no attribute 'IAuthenticator'
2022-12-05 11:58:18,034:ERROR:certbot._internal.log:An unexpected error occurred:
2022-12-05 11:58:18,035:ERROR:certbot._internal.log:AttributeError: module 'certbot.interfaces' has no attribute 'IAuthenticator'
obynio commented 1 year ago

This is expected because of the mess created by certbot, see the PR. There is no workaround appart from downgrading the certbot installation because certbot removed the zope.interface in their latest release.

They are aware of the issue and I think they plan to reintroduce the missing package in their next release. There is no ETA so we can only wait and see I guess 🤷‍♂️

HLFH commented 1 year ago

@JulienPalard Certbot 2.1.0 has not been released yet. This PR https://github.com/obynio/certbot-plugin-gandi/pull/41 fixed the compatibility with Certbot < 2.0.0 & Certbot >= 2.1.0, but drops the support for Certbot 2.0.0 because Certbot has decided as well to drop the support for its own version 2.0.0. If you want to use Certbot 2.0.0, you need to use the version 1.4.1 (not 1.4.2) of certbot-plugin-gandi and apply this commit/patch manually probably located at /usr/lib/python3.10/site-packages/certbot_plugin_gandi/main.py:

Unit193 commented 1 year ago

Wouldn't it be easy enough to fix it with the patch below? Seemed to work with certbot 1.31.0 and 2.0.0. I don't have 2.1.0 anywhere.

diff --git a/certbot_plugin_gandi/main.py b/certbot_plugin_gandi/main.py
index 55c075b..8e0b777 100644
--- a/certbot_plugin_gandi/main.py
+++ b/certbot_plugin_gandi/main.py
@@ -15,11 +15,10 @@ def register_authenticator(cls):
     try:
         interfaces.Authenticator.register(cls)
     except AttributeError:
-        pass
-    zope.interface.implementer(interfaces.IAuthenticator)(cls)
-    zope.interface.provider(interfaces.IPluginFactory)(cls)
-    return cls
-
+        zope.interface.implementer(interfaces.IAuthenticator)(cls)
+        zope.interface.provider(interfaces.IPluginFactory)(cls)
+    return cls
+
 @register_authenticator
 class Authenticator(dns_common.DNSAuthenticator):
     """DNS Authenticator for Gandi (using LiveDNS)."""
HLFH commented 1 year ago

@Unit193 Yes, no one has Certbot 2.1.0 yet as it is not released. https://community.letsencrypt.org/t/breaking-changes-certbot-2-1-0-release/189036 The Certbot wiki is the reference and we will have to wait. https://github.com/certbot/certbot/wiki/Certbot-v2.x-Plugin-Compatibility.

Unit193 commented 1 year ago

Well, one could have tested it on a pre-release or git snapshot. I didn't.

I went with a slightly different approach. The main benefit here is that one can rely on certbot to depend on zope or not, and if one is on 2.x+, get rid of zope.

I have now tested it on 1.31, 2.0, and 2.1 so I'm pretty happy with it.

obynio commented 1 year ago

Well, some might disagree but since we do not have any ETA for the release of Certbot 2.1.0 I will adopt the solution provided by @Unit193 and release a version 1.4.3 with his fix.

obynio commented 1 year ago

It is done. Thanks @Unit193 for the suggestion 👍

HLFH commented 1 year ago

Certbot 2.1.0 has been released yesterday. As seen here: https://github.com/certbot/certbot/releases/tag/v2.1.0 And here: https://community.letsencrypt.org/t/breaking-changes-certbot-2-1-0-release/189036/7

Unit193 commented 1 year ago

Thanks for taking my fix, glad it could help.

HLFH commented 1 year ago

Shall we close this issue now it works for most of Certbot versions and that Certbot 2.1.0 has been released?

fkhn commented 1 year ago

Thanks for that fast adaptation to the certbot changes.

JulienPalard commented 1 year ago

I tried today with:

acme                 2.1.0
certbot              2.1.0
certbot-plugin-gandi 1.4.3

I was only able to do a --dry-run but it worked! Thanks for all involved ♥