'certbot.plugins.common' has no attribute 'TLSSNI01'

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: https://dismyserver.net (certificate will not be installed here)

I ran this command:

sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /home/rooot/cloudflare_creds.txt -d dismyserver.net,*.dismyserver.net --preferred-challenges dns-01

It produced this output:

An unexpected error occurred:
AttributeError: module ‘certbot.plugins.common’ has no attribute ‘TLSSNI01’
Please see the logfile ‘/tmp/tmphmjxfvpe/log’ for more details.

(logfile)

2020-01-01 09:47:47,472:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/certbot/main.py", line 14, in main
    return internal_main.main(cli_args)
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/main.py", line 1320, in main
    plugins = plugins_disco.PluginsRegistry.find_all()
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/plugins/disco.py", line 208, in find_all
    plugin_ep = PluginEntryPoint(entry_point)
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/plugins/disco.py", line 50, in __init__
    self.plugin_cls = entry_point.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/certbot_apache/entrypoint.py", line 4, in <module>
    from certbot_apache import configurator
  File "/usr/lib/python3/dist-packages/certbot_apache/configurator.py", line 32, in <module>
    from certbot_apache import http_01
  File "/usr/lib/python3/dist-packages/certbot_apache/http_01.py", line 13, in <module>
    class ApacheHttp01(common.TLSSNI01):
  File "/usr/local/lib/python3.6/dist-packages/certbot/plugins/common.py", line 445, in __getattr__
    return getattr(self._module, attr)
AttributeError: module 'certbot.plugins.common' has no attribute 'TLSSNI01'
2020-01-01 09:47:47,472:ERROR:certbot._internal.log:An unexpected error occurred:

My web server is (include version):

Server version: Apache/2.4.29 (Ubuntu)
Server built: 2019-09-16T12:58:48

The operating system my web server runs on is (include version):

Ubuntu 18.04.3 LTS

I can login to a root shell on my machine (yes or no, or I don’t know): yes

I’m using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot):

certbot --version produces the same error as the command I tried above.

apt-cache policy certbot | grep -i installed
Installed: 0.31.0-1+ubuntu18.04.1+certbot+1

I also updated all the packages on my server to attempt to resolve this, but I am still receiving the error.

1 Like

It looks like you have at least two installations of different, incompatible versions of Certbot mixed together.

Do you know why?

A simple option might be to remove the installation from /usr/local and keep the – probably older – one in /usr.

Edit:

What are the first few lines of the /usr/local/bin/certbot file?

1 Like

I do not know why there would be multiple installations installed. I believe I only have certbot installed through apt. When I move the certbot or certbot_apache directories out of the dist-packages directories and attempt certbot --version I get the following errors:

An unexpected error occurred:
ModuleNotFoundError: No module named 'certbot._internal'
Please see the logfile '/tmp/tmptxj9yfwt' for more details.
2020-01-01 12:30:46,367:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 1335, in main
    plugins = plugins_disco.PluginsRegistry.find_all()
  File "/usr/lib/python3/dist-packages/certbot/plugins/disco.py", line 206, in find_all
    plugin_ep = PluginEntryPoint(entry_point)
  File "/usr/lib/python3/dist-packages/certbot/plugins/disco.py", line 52, in __init__
    self.plugin_cls = entry_point.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'certbot._internal'
2020-01-01 12:30:46,367:ERROR:certbot.log:An unexpected error occurred:

An unexpected error occurred:
ModuleNotFoundError: No module named ‘certbot_apache’
Please see the logfile ‘/tmp/tmpmc5mf31q/log’ for more details.

2020-01-01 12:36:39,223:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/certbot/main.py", line 14, in main
    return internal_main.main(cli_args)
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/main.py", line 1320, in main
    plugins = plugins_disco.PluginsRegistry.find_all()
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/plugins/disco.py", line 208, in find_all
    plugin_ep = PluginEntryPoint(entry_point)
  File "/usr/local/lib/python3.6/dist-packages/certbot/_internal/plugins/disco.py", line 50, in __init__
    self.plugin_cls = entry_point.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'certbot_apache'
2020-01-01 12:36:39,224:ERROR:certbot._internal.log:An unexpected error occurred:

The entire /usr/local/bin/certbot file is below:

#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from certbot.main import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
1 Like

I installed certbot on a new server to accomplish this and everything worked fine. What’s the best way to (back up and) purge all the configs from this installation to reinstall certbot from scratch?

1 Like

@bmw I totally agree with @mnordhoff’s diagnosis here; do you have any suggestions about how to recover from this?

1 Like

See also

1 Like

Certbot installations in /usr/local are almost always was caused by installing Certbot globally through pip which is not supported by Certbot. Installing any Python packages in this way can cause problems like this because pip and your OS package manager do not work well together. Using both package managers to install Python packages can result in conflicting dependencies or broken installations because the two package managers improperly modify packages installed by the other.

To fix this, I would remove all packages installed through pip by running the command below.

WARNING: You should only run this command on Debian based systems such as Ubuntu because on some other OSes the command will improperly remove Python packages installed by your OS package manager.

sudo pip3 uninstall -y -r <(pip3 freeze)

3 Likes

That sounds like a bit of a nuclear option to wipe my entire python package list. I looked it over and some seem important (ufw,fail2ban,PAM) and I don’t know what most of the others do. These few look like all that are related to certbot, would it be better to remove just these?

acme==0.40.0
certbot==1.0.0
certbot-apache==0.31.0
certbot-dns-cloudflare==1.0.0
cloudflare==2.3.1

Here is the whole list of packages that I have installed in case I missed any. I’d rather not just delete everything that’s installed.

acme==0.40.0 docker-pycreds==0.2.1 oauthlib==2.0.6 python-augeas==0.5.0
asn1crypto==0.24.0 fail2ban==0.10.2 olefile==0.45.1 python-dateutil==2.6.1
attrs==17.4.0 future==0.15.2 PAM==0.4.2 python-debian==0.1.32
Automat==0.6.0 Glances==2.11.1 parsedatetime==2.4 pytz==2018.3
blinker==1.4 httplib2==0.9.2 pbr==3.1.1 pyxdg==0.25
bottle==0.12.13 hyperlink==17.3.1 Pillow==5.1.0 PyYAML==3.12
certbot==1.0.0 idna==2.6 ply==3.11 requests==2.18.4
certbot-apache==0.31.0 incremental==16.10.1 psutil==5.4.2 requests-toolbelt==0.8.0
certbot-dns-cloudflare==1.0.0 influxdb==4.1.1 pyasn1==0.4.2 requests-unixsocket==0.1.5
certifi==2018.1.18 Jinja2==2.10 pyasn1-modules==0.2.1 SecretStorage==2.3.1
chardet==3.0.4 josepy==1.1.0 pycrypto==2.6.1 service-identity==16.0.0
click==6.7 jsonlines==1.2.0 pycryptodomex==3.4.7 six==1.11.0
cloud-init==19.3 jsonpatch==1.16 pygobject==3.26.1 speedtest-cli==2.0.0
cloudflare==2.3.1 jsonpointer==1.10 PyICU==1.9.8 ssh-import-id==5.7
colorama==0.3.7 jsonschema==2.6.0 pyinotify==0.9.6 systemd-python==234
command-not-found==0.3 keyring==10.6.0 PyJWT==1.5.3 Twisted==17.9.0
ConfigArgParse==0.11.0 keyrings.alt==3.0 pyOpenSSL==17.5.0 ufw==0.36
configobj==5.0.6 language-selector==0.1 pyparsing==2.2.0 unattended-upgrades==0.1
constantly==15.1.0 MarkupSafe==1.0 pyRFC3339==1.0 urllib3==1.22
cryptography==2.1.4 matplotlib==2.1.1 pyserial==3.4 websocket-client==0.44.0
cycler==0.10.0 mock==2.0.0 pysmi==0.2.2 zope.component==4.3.0
distro==1.4.0 ndg-httpsclient==0.4.4 pysnmp==4.4.3 zope.event==4.2.0
distro-info===0.18ubuntu0.18.04.1 netifaces==0.10.4 pystache==0.5.4 zope.hookable==4.0.4
docker==2.5.1 numpy==1.13.3 python-apt==1.6.4 zope.interface==4.3.2

Can you check which packages are actually installed in /usr/local? In particular, in /usr/local/lib/python3.6/dist-packages/.

Given certbot_apache's version – and its path in the earlier error messages – it’s likely part of the apt package.

And the acme package is an oddly in-between version.

FYI:

python-cloudflare is Cloudflare’s official Python library/client. It’s a dependency of certbot-dns-cloudflare, but it’s not part of Certbot.

josepy is developed by the Certbot project, though it’s separated into an independent library. If you’re getting rid of other Certbot parts, you should probably also get rid of it.


Many of the other libraries in the table were likely installed because they’re dependencies of Certbot. Also, many weren’t.

I’m perfectly fine uninstalling certbot from both apt and pip and starting fresh, I just feel like nuking my python package list is overkill. My /usr/local/lib/python3.6/dist-packages directory has the following packages installed:

acme                                    cloudflare-2.3.1.egg-info
acme-0.40.0.dist-info                   distro-1.4.0.dist-info
certbot                                 distro.py
certbot-1.0.0.dist-info                 examples
certbot_dns_cloudflare                  jsonlines
certbot_dns_cloudflare-1.0.0.dist-info  jsonlines-1.2.0.dist-info
cli4                                    __pycache__
CloudFlare

Thank you all for your assistance so far, I really do appreciate it!

1 Like

On Debian based systems, the command I suggested above won’t remove all of the packages output by pip freeze. It will remove all packages installed by pip and for packages installed through apt, you’ll get a message like:

Not uninstalling foo at /usr/lib/python3/dist-packages, outside environment /usr

When I wrote my comment I wasn’t aware of a way to make pip freeze only list packages installed through pip at the time, but pip3 freeze --local seems to work so you could use that in the command instead if you want.

Alternatively, you certainly could only remove some of the packages installed through pip like you said which would fix the problem you’re having here, however, I personally recommend removing all of them unless you have a good reason not to do so.

4 Likes

My apologies, I completely lost track of this. I ran pip3 uninstall -y -r <(pip3 freeze --local) and everything is working again.

Thank you all very much for your help!

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.