Failed to Certbot-auto the first time

**My domain is: ** expehr.mynetgear.com (DDNS domain name)

I ran this command: sudo /usr/local/bin/certbot-auto --apache

It produced this output:
Bootstrapping dependencies for RedHat-based OSes that will use Python3… (you can skip this with --no-bootstrap)

dnf is /bin/dnf

dnf is hashed (/bin/dnf)

Last metadata expiration check: 0:09:08 ago on Sat 29 Aug 2020 21:29:56 AEST.

Package gcc-8.3.1-5.el8.0.2.x86_64 is already installed.

Package augeas-libs-1.12.0-5.el8.x86_64 is already installed.

Package openssl-1:1.1.1c-15.el8.x86_64 is already installed.

Package openssl-devel-1:1.1.1c-15.el8.x86_64 is already installed.

Package libffi-devel-3.1-21.el8.x86_64 is already installed.

Package redhat-rpm-config-122-1.el8.noarch is already installed.

Package ca-certificates-2020.2.41-80.0.el8_2.noarch is already installed.

Package python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed.

Package python3-virtualenv-15.1.0-19.module_el8.1.0+245+c39af44f.noarch is already installed.

Package python36-devel-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed.

Package mod_ssl-1:2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 is already installed.

Dependencies resolved.

Nothing to do.

Complete!

Bootstrapping dependencies for RedHat-based OSes that will use Python3… (you can skip this with --no-bootstrap)

dnf is /bin/dnf

dnf is hashed (/bin/dnf)

Last metadata expiration check: 0:09:11 ago on Sat 29 Aug 2020 21:29:56 AEST.

Package gcc-8.3.1-5.el8.0.2.x86_64 is already installed.

Package augeas-libs-1.12.0-5.el8.x86_64 is already installed.

Package openssl-1:1.1.1c-15.el8.x86_64 is already installed.

Package openssl-devel-1:1.1.1c-15.el8.x86_64 is already installed.

Package libffi-devel-3.1-21.el8.x86_64 is already installed.

Package redhat-rpm-config-122-1.el8.noarch is already installed.

Package ca-certificates-2020.2.41-80.0.el8_2.noarch is already installed.

Package python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed.

Package python3-virtualenv-15.1.0-19.module_el8.1.0+245+c39af44f.noarch is already installed.

Package python36-devel-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed.

Package mod_ssl-1:2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64 is already installed.

Dependencies resolved.

Nothing to do.

Complete!

Creating virtual environment…

Error: Command ‘[’/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 2.

Traceback (most recent call last):

File “”, line 27, in

File “”, line 23, in create_venv

File “/usr/lib64/python3.6/subprocess.py”, line 311, in check_call

raise CalledProcessError(retcode, cmd)

subprocess.CalledProcessError: Command ‘[’/bin/python3’, ‘-m’, ‘venv’, ‘/opt/eff.org/certbot/venv’]’ returned non-zero exit status 1.

My web server is (include version): Apache/2.4.37

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

My hosting provider, if applicable, is: N/A

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):

1 Like

Is there a reason why you’re using the certbot-auto script? I don’t have a clue what’s going on here, but the certbot instructions for CentOS 8 and the Apache webserver instruct you to use the certbot packages from the CentOS/Fedora EPEL repository and install the packages using dnf.

Also, like in the instruction, you could try the certbot snap, which will become the recommended way of installling certbot.

1 Like

Thanks Osiris,

Sorry for my stupid question as a new Certboter.

I just tried certbot snap. It was all good until I ran ‘certbot --apache’.

Here is the error:

*** stack smashing detected ***: terminated
An unexpected error occurred:
OSError: [Errno 5] Input/output error
Please see the logfile ‘/tmp/tmprpcfef2s/log’ for more details.

Here is the log file:

2020-08-29 23:31:45,009:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File “/snap/certbot/500/bin/certbot”, line 8, in
sys.exit(main())
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/main.py”, line 15, in main
return internal_main.main(cli_args)
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/_internal/main.py”, line 1323, in main
plugins = plugins_disco.PluginsRegistry.find_all()
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/_internal/plugins/disco.py”, line 236, in find_all
plugin_ep = cls._load_entry_point(entry_point, plugins, with_prefix=False)
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/_internal/plugins/disco.py”, line 251, in _load_entry_point
plugin_ep = PluginEntryPoint(entry_point, with_prefix)
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/_internal/plugins/disco.py”, line 56, in init
self.plugin_cls = entry_point.load()
File “/snap/certbot/500/lib/python3.8/site-packages/pkg_resources/init.py”, line 2443, in load
return self.resolve()
File “/snap/certbot/500/lib/python3.8/site-packages/pkg_resources/init.py”, line 2449, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/snap/certbot/500/lib/python3.8/site-packages/certbot/_internal/plugins/standalone.py”, line 13, in
from acme import standalone as acme_standalone
File “/snap/certbot/500/lib/python3.8/site-packages/acme/standalone.py”, line 8, in
from six.moves import BaseHTTPServer # type: ignore
File “”, line 1039, in _handle_fromlist
File “/snap/certbot/500/lib/python3.8/site-packages/six.py”, line 92, in get
result = self._resolve()
File “/snap/certbot/500/lib/python3.8/site-packages/six.py”, line 115, in _resolve
return _import_module(self.mod)
File “/snap/certbot/500/lib/python3.8/site-packages/six.py”, line 82, in _import_module
import(name)
File “/snap/certbot/500/usr/lib/python3.8/http/server.py”, line 628, in
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File “/snap/certbot/500/usr/lib/python3.8/http/server.py”, line 880, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 364, in init
db.read(file)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 206, in read
self.readfp(fp, strict)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 217, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error
2020-08-29 23:31:45,009:ERROR:certbot._internal.log:An unexpected error occurred:
2020-08-29 23:31:45,009:ERROR:certbot._internal.log:OSError: [Errno 5] Input/output error

1 Like

You’re not asking stupid questions. I was genuinely curious: perhaps you were following some kind of guide or perhaps other methods didn’t work.

Further more, I have absolutely no idea what all those Python errors mean. Could you, for completeness, tell us how you installed the certbot snap?

@bmw Sorry for tagging you again, but I’m struggeling with snap based certbot errors… How should we, as a Community, try to tackle these things? As snap is rather new, is there perhaps a crew list specific for snap we could tag? Or should I continue harassing you? :stuck_out_tongue:

Hmm, could it be because the files the mimetypes.py from the mimetypes library tries to access hardcoded paths outside the snap environment?:

Strangely enough there is a check if the file exists or not:

But apparently @Raymond14 still gets an “OSError”…

1 Like

Here is what I did to install certbot snap:

sudo dnf install epel-release
sudo dnf upgrade
sudo yum remove certbot
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

Restart server

sudo snap install --classic certbot

1 Like

Thanks for asking this Osiris. I think the best way for the community to flag something that needs a Certbot developer’s attention is to create an issue on our GitHub at https://github.com/certbot/certbot/issues/new. We take turns responding to new issues so by creating an issue, requests will get spread out among the team.

@Raymond14, if you install python3 by running sudo yum install python3 and then run sudo python3 -c 'import http.server', do you get the same error?

What’s the output if you run:

cd $(mktemp -d)
cat << EOF > test.py
import mimetypes
import os.path

db = mimetypes.MimeTypes()
for f in mimetypes.knownfiles:
    if os.path.isfile(f):
        try:
            db.read(f)
        except Exception:
            print('Failed to load', f)
            raise
print('Loaded all files successfully')
EOF
sudo python3 test.py
sudo snap run --shell certbot.certbot -c 'python3 test.py'

This runs commands similar to the commands that the Python standard library in the Certbot snap crashed on, testing the Python installation inside the Certbot snap as well as the global Python 3 installation, with additional print statements added to help with debugging.

Hi @bmw ,

Thanks for the reply.

Here is the Output for installing python3:

sudo yum install python3
Last metadata expiration check: 1:26:09 ago on Tue 01 Sep 2020 22:29:02 AEST.
Package python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

python3 -c 'import http.server’
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib64/python3.6/http/server.py”, line 619, in
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File “/usr/lib64/python3.6/http/server.py”, line 827, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File “/usr/lib64/python3.6/mimetypes.py”, line 355, in init
db.read(file)
File “/usr/lib64/python3.6/mimetypes.py”, line 205, in read
self.readfp(fp, strict)
File “/usr/lib64/python3.6/mimetypes.py”, line 216, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error

The output to run the script:

Traceback (most recent call last):
File “test.py”, line 4, in
db = mimetypes.MimeTypes()
File “/usr/lib64/python3.6/mimetypes.py”, line 68, in init
init()
File “/usr/lib64/python3.6/mimetypes.py”, line 355, in init
db.read(file)
File “/usr/lib64/python3.6/mimetypes.py”, line 205, in read
self.readfp(fp, strict)
File “/usr/lib64/python3.6/mimetypes.py”, line 216, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error
Traceback (most recent call last):
File “test.py”, line 4, in
db = mimetypes.MimeTypes()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 68, in init
init()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 364, in init
db.read(file)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 206, in read
self.readfp(fp, strict)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 217, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error

Very strange, even the normal Python results in an error… Is this an “out of the box” CentOS 8? Edit: No such error on my fresh out of the box minimal CentOS 8 in VirtualBox…

Further more, I’m interested to see which of the following files exist on your system:

Could you therefore run for example:

ls -l /etc/mime.types /etc/httpd/mime.types /etc/httpd/conf/mime.types /etc/apache/mime.types /etc/apache2/mime.types /usr/local/etc/httpd/conf/mime.types /usr/local/lib/netscape/mime.types /usr/local/etc/httpd/conf/mime.types /usr/local/etc/mime.types

(That’s a single line.)

Also, personally I love “quick 'n dirty” debugging. So for example, I would add a simple “print” line in the function which could identify when the error occurs.

Now the “read()” function of mimetypes.py reads:

You could temporarily add a little print line in /usr/lib64/python3.6/mimetypes.py so it reads:

    def read(self, filename, strict=True):
        """
        Read a single mime.types-format file, specified by pathname.
        If strict is true, information will be added to
        list of standard types, else to the list of non-standard
        types.
        """
        print("Trying to open and read file: {}".format(filename))
        with open(filename, encoding='utf-8') as fp:
            self.readfp(fp, strict)
        print("Succesfully opened and read file: {}".format(filename))

It is not ‘out of box’ Centos 8. Maria DB, Apache and Wordpress are installed on it. I wanted to use self-signed certificate. But since there is something wrong with the newly installed Wordpress, I would like to try Ltesencrypt.

It seems like only /etc/mime.types is existing:

ls: cannot access ‘/etc/httpd/mime.types’: No such file or directory
ls: cannot access ‘/etc/httpd/conf/mime.types’: No such file or directory
ls: cannot access ‘/etc/apache/mime.types’: No such file or directory
ls: cannot access ‘/etc/apache2/mime.types’: No such file or directory
ls: cannot access ‘/usr/local/etc/httpd/conf/mime.types’: No such file or directory
ls: cannot access ‘/usr/local/lib/netscape/mime.types’: No such file or directory
ls: cannot access ‘/usr/local/etc/httpd/conf/mime.types’: No such file or directory
ls: cannot access ‘/usr/local/etc/mime.types’: No such file or directory
-rw-r–r--. 1 root root 60352 May 11 2017 /etc/mime.types

@Osiris, what do you want me to try after adding those 2 ‘print’ line into /usr/lib64/python3.6/mimetypes.py ? Thanks.

Could you run the Python script posted earlier again?

Traceback (most recent call last):
File “test.py”, line 1, in
import mimetypes
File “/usr/lib64/python3.6/mimetypes.py”, line 204
print(“Trying to open and read file: {}”.format(filename))
^
TabError: inconsistent use of tabs and spaces in indentation
Traceback (most recent call last):
File “test.py”, line 4, in
db = mimetypes.MimeTypes()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 68, in init
init()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 364, in init
db.read(file)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 206, in read
self.readfp(fp, strict)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 217, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error

Did you add both print lines and did you use the exact same indentation? Python is very picky about that. And I assume I used the correct indentation, but if someone could correct me if I didn’t, please let me know.

Sorry, I just realized that I used tab instead of spaces in front of ‘print’ lol

Here we go:

Trying to open and read file: /etc/mime.types
Traceback (most recent call last):
File “test.py”, line 4, in
db = mimetypes.MimeTypes()
File “/usr/lib64/python3.6/mimetypes.py”, line 68, in init
init()
File “/usr/lib64/python3.6/mimetypes.py”, line 357, in init
db.read(file)
File “/usr/lib64/python3.6/mimetypes.py”, line 206, in read
self.readfp(fp, strict)
File “/usr/lib64/python3.6/mimetypes.py”, line 218, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error
Traceback (most recent call last):
File “test.py”, line 4, in
db = mimetypes.MimeTypes()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 68, in init
init()
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 364, in init
db.read(file)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 206, in read
self.readfp(fp, strict)
File “/snap/certbot/500/usr/lib/python3.8/mimetypes.py”, line 217, in readfp
line = fp.readline()
OSError: [Errno 5] Input/output error

In order to give more background details, here is my post in Wordpress.org forum.

So it fails with the file actually existing, which makes sense, as the script first checks if the file is there or not. So that latter check is working properly. But why wouldn’t Python just open that file? Very strange…

Yeah this is a weird one.

Does running the following also fail with the same OSError?

cd $(mktemp -d)
cat << EOF > test.py
with open('/etc/mime.types', encoding='utf-8') as fp:
    while 1:
        if not fp.readline():
            break
print('Read file successfully')
EOF
sudo python3 test.py

What about the trivial:

cd $(mktemp -d)
cat << EOF > test.py
with open('/etc/mime.types') as fp:
    fp.read()
print('Read file successfully')
EOF
sudo python3 test.py

The file /etc/mime.types on your system may be corrupted, however, the modification date and size matches what I have on a clean CentOS 8 installation.

The fact that this is occurring with both the Certbot snap and your system Python is pretty odd, especially considering that the Certbot snap tries to be completely self contained with its own copy of Python, shared libraries like libc, etc.

@bmw

The first script output:
Traceback (most recent call last):
File “test.py”, line 3, in
if not fp.readline():
OSError: [Errno 5] Input/output error

The second script output:
Traceback (most recent call last):
File “test.py”, line 2, in
fp.read()
OSError: [Errno 5] Input/output error

Is this a specific Python thing? Or OS thing? Can you view the file? For example, cat /etc/mime.types