Letsencrypt cert renew error (str returned non-string - SysCallError)

NethServer Version: 7.9.2009 (final)
Module: certbot

Hi,

a few days ago, Nethserver sent me the following message:

/etc/cron.daily/nethserver-letsencrypt-certs:
An unexpected error occurred:
TypeError: str returned non-string (type SysCallError)
Please see the logfiles in /var/log/letsencrypt for more details.

The letsenrcypt.log has the following (cat /var/log/letsencrypt/letsencrypt.log):

2024-09-16 07:07:48,688:DEBUG:certbot.internal.main:certbot version: 1.11.0
2024-09-16 07:07:48,688:DEBUG:certbot.internal.main:Location of certbot entry point: /usr/bin/certbot
2024-09-16 07:07:48,688:DEBUG:certbot.internal.main:Arguments: [‘–text’, ‘–non-interactive’, ‘–agree-tos’, ‘–register-unsafely-without-email’, ‘–preferred-challenges’, ‘http’, ‘–webroot’, ‘–webroot-path’, ‘/var/www/html/’, ‘-d’, 'nethserver.
___.eu’, ‘–preferred-chain’, ‘ISRG Root X1’, ‘–quiet’]
2024-09-16 07:07:48,688:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2024-09-16 07:07:48,720:DEBUG:certbot.internal.log:Root logging level set at 30
2024-09-16 07:07:48,720:INFO:certbot.internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2024-09-16 07:07:48,720:DEBUG:certbot.internal.plugins.selection:Requested authenticator webroot and installer None
2024-09-16 07:07:48,723:DEBUG:certbot.internal.plugins.selection:Single candidate plugin: * webroot
Description: Place files in webroot directory
Interfaces: IAuthenticator, IPlugin
Entry point: webroot = certbot.internal.plugins.webroot:Authenticator
Initialized: <certbot.internal.plugins.webroot.Authenticator object at 0x7f24f4217f90>
Prep: True
2024-09-16 07:07:48,723:DEBUG:certbot.internal.plugins.selection:Selected authenticator <certbot.internal.plugins.webroot.Authenticator object at 0x7f24f4217f90> and installer None
2024-09-16 07:07:48,723:INFO:certbot.internal.plugins.selection:Plugins selected: Authenticator webroot, Installer None
2024-09-16 07:07:48,774:DEBUG:certbot.internal.main:Picked account: <Account(RegistrationResource(body=Registration(status=None, terms_of_service_agreed=None, agreement=None, only_return_existing=None, contact=(), key=None, external_account_binding=None), uri=u’https://acme-v02.api.letsencrypt.org/acme/acct/252893710’, new_authzr_uri=None, terms_of_service=None), 5cfbe89626779fda6fa21b007ff2a44a, Meta(creation_host=u’nethserver.
.eu’, register_to_eff=None, creation_dt=datetime.datetime(2021, 10, 24, 13, 40, 53, tzinfo=)))>
2024-09-16 07:07:48,784:DEBUG:acme.client:Sending GET request to https://acme-v02.api.letsencrypt.org/directory.
2024-09-16 07:07:48,794:INFO:urllib3.connectionpool:Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
2024-09-16 07:08:08,297:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File “/usr/bin/certbot”, line 9, in
load_entry_point(‘certbot==1.11.0’, ‘console_scripts’, ‘certbot’)()
File “/usr/lib/python2.7/site-packages/certbot/main.py”, line 15, in main
return internal_main.main(cli_args)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1421, in main
return config.func(config, plugins)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1277, in certonly
le_client = _init_le_client(config, auth, installer)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 659, in _init_le_client
return client.Client(config, acc, authenticator, installer, acme=acme)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 255, in init
acme = acme_from_config_key(config, self.account.key, self.account.regr)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 43, in acme_from_config_key
return acme_client.BackwardsCompatibleClientV2(net, key, config.server)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 831, in init
directory = messages.Directory.from_json(net.get(server).json())
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1168, in get
self._send_request(‘GET’, url, **kwargs), content_type=content_type)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1118, in _send_request
response = self.session.request(method, url, *args, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 486, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 598, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/adapters.py”, line 370, in send
timeout=timeout
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 544, in urlopen
body=body, headers=headers)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 314, in _raise_timeout
if ‘timed out’ in str(err) or ‘did not complete (read)’ in str(err): # Python 2.6
TypeError: str returned non-string (type SysCallError)
2024-09-16 07:08:08,307:ERROR:certbot._internal.log:An unexpected error occurred:
2024-09-16 07:08:08,308:ERROR:certbot._internal.log:TypeError: str returned non-string (type SysCallError)

The curl returns this (curl -i https://acme-v02.api.letsencrypt.org/directory):

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 16 Sep 2024 07:29:32 GMT
Content-Type: application/json
Content-Length: 746
Connection: keep-alive
Cache-Control: public, max-age=0, no-cache
X-Frame-Options: DENY
Strict-Transport-Security: max-age=604800

{
“0ufTl382iGI”: “Adding random entries to the directory - API Announcements - Let's Encrypt Community Support”,
“keyChange”: “https://acme-v02.api.letsencrypt.org/acme/key-change”,
“meta”: {
“caaIdentities”: [
letsencrypt.org
],
“termsOfService”: “https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf”,
“website”: “https://letsencrypt.org
},
“newAccount”: “https://acme-v02.api.letsencrypt.org/acme/new-acct”,
“newNonce”: “https://acme-v02.api.letsencrypt.org/acme/new-nonce”,
“newOrder”: “https://acme-v02.api.letsencrypt.org/acme/new-order”,
“renewalInfo”: “https://acme-v02.api.letsencrypt.org/draft-ietf-acme-ari-03/renewalInfo”,
“revokeCert”: “https://acme-v02.api.letsencrypt.org/acme/revoke-cert

The python version:

Python 2.7.5

Can anyone help? What could be the cause of the problem and how can it be fixed?

Thank you for your help.

Topic splitted. Last relevant message to this topic from original author:

Same here on 2 of 4 Installations:

Environment 1:

2024-10-07 20:39:21,479:DEBUG:certbot._internal.main:certbot version: 1.11.0
2024-10-07 20:39:21,479:DEBUG:certbot._internal.main:Location of certbot entry point: /usr/bin/certbot
2024-10-07 20:39:21,479:DEBUG:certbot._internal.main:Arguments: [‘–text’, ‘–non-interactive’, ‘–agree-tos’, ‘–email’, ‘report@environment1.tld’, ‘–preferred-challenges’, ‘http’, ‘–webroot’, ‘–webroot-path’, ‘/var/www/html/’, ‘-d’, ‘sub.environment1.tld’, ‘–test-cert’, ‘–preferred-chain’, ‘ISRG Root X1’, ‘–quiet’]
2024-10-07 20:39:21,479:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2024-10-07 20:39:21,608:DEBUG:certbot._internal.log:Root logging level set at 30
2024-10-07 20:39:21,608:INFO:certbot._internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2024-10-07 20:39:21,610:DEBUG:certbot._internal.plugins.selection:Requested authenticator webroot and installer None
2024-10-07 20:39:21,614:DEBUG:certbot._internal.plugins.selection:Single candidate plugin: * webroot
Description: Place files in webroot directory
Interfaces: IAuthenticator, IPlugin
Entry point: webroot = certbot._internal.plugins.webroot:Authenticator
Initialized: <certbot._internal.plugins.webroot.Authenticator object at 0x7fc3946fa150>
Prep: True
2024-10-07 20:39:21,615:DEBUG:certbot._internal.plugins.selection:Selected authenticator <certbot._internal.plugins.webroot.Authenticator object at 0x7fc3946fa150> and installer None
2024-10-07 20:39:21,615:INFO:certbot._internal.plugins.selection:Plugins selected: Authenticator webroot, Installer None
2024-10-07 20:39:22,347:DEBUG:acme.client:Sending GET request to https://acme-staging-v02.api.letsencrypt.org/directory.
2024-10-07 20:39:22,374:INFO:urllib3.connectionpool:Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
2024-10-07 20:39:22,422:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File “/usr/bin/certbot”, line 9, in
load_entry_point(‘certbot==1.11.0’, ‘console_scripts’, ‘certbot’)()
File “/usr/lib/python2.7/site-packages/certbot/main.py”, line 15, in main
return internal_main.main(cli_args)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1421, in main
return config.func(config, plugins)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1277, in certonly
le_client = _init_le_client(config, auth, installer)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 652, in _init_le_client
acc, acme = _determine_account(config)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 570, in _determine_account
config, account_storage, tos_cb=_tos_cb)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 173, in register
acme = acme_from_config_key(config, key)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 43, in acme_from_config_key
return acme_client.BackwardsCompatibleClientV2(net, key, config.server)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 831, in init
directory = messages.Directory.from_json(net.get(server).json())
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1168, in get
self._send_request(‘GET’, url, **kwargs), content_type=content_type)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1118, in _send_request
response = self.session.request(method, url, *args, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 486, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 598, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/adapters.py”, line 370, in send
timeout=timeout
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 544, in urlopen
body=body, headers=headers)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 314, in _raise_timeout
if ‘timed out’ in str(err) or ‘did not complete (read)’ in str(err): # Python 2.6
TypeError: str returned non-string (type Error)
2024-10-07 20:39:22,430:ERROR:certbot._internal.log:An unexpected error occurred:
2024-10-07 20:39:22,430:ERROR:certbot._internal.log:TypeError: str returned non-string (type Error)

Environment 2:

2024-10-07 21:23:31,329:DEBUG:certbot._internal.main:certbot version: 1.11.0
2024-10-07 21:23:31,329:DEBUG:certbot._internal.main:Location of certbot entry point: /usr/bin/certbot
2024-10-07 21:23:31,330:DEBUG:certbot._internal.main:Arguments: [‘–text’, ‘–non-interactive’, ‘–agree-tos’, ‘–email’, ‘report@environment2.tld’, ‘–preferred-challenges’, ‘http’, ‘–webroot’, ‘–webroot-path’, ‘/var/www/html/’, ‘-d’, ‘sub.environment2.tld’, ‘–test-cert’, ‘–preferred-chain’, ‘ISRG Root X1’, ‘–quiet’]
2024-10-07 21:23:31,330:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2024-10-07 21:23:31,510:DEBUG:certbot._internal.log:Root logging level set at 30
2024-10-07 21:23:31,511:INFO:certbot._internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2024-10-07 21:23:31,513:DEBUG:certbot._internal.plugins.selection:Requested authenticator webroot and installer None
2024-10-07 21:23:31,519:DEBUG:certbot._internal.plugins.selection:Single candidate plugin: * webroot
Description: Place files in webroot directory
Interfaces: IAuthenticator, IPlugin
Entry point: webroot = certbot._internal.plugins.webroot:Authenticator
Initialized: <certbot._internal.plugins.webroot.Authenticator object at 0x7f40b2cdbf10>
Prep: True
2024-10-07 21:23:31,520:DEBUG:certbot._internal.plugins.selection:Selected authenticator <certbot._internal.plugins.webroot.Authenticator object at 0x7f40b2cdbf10> and installer None
2024-10-07 21:23:31,520:INFO:certbot._internal.plugins.selection:Plugins selected: Authenticator webroot, Installer None
2024-10-07 21:23:31,948:DEBUG:acme.client:Sending GET request to https://acme-staging-v02.api.letsencrypt.org/directory.
2024-10-07 21:23:31,991:INFO:urllib3.connectionpool:Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
2024-10-07 21:23:32,052:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File “/usr/bin/certbot”, line 9, in
load_entry_point(‘certbot==1.11.0’, ‘console_scripts’, ‘certbot’)()
File “/usr/lib/python2.7/site-packages/certbot/main.py”, line 15, in main
return internal_main.main(cli_args)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1421, in main
return config.func(config, plugins)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 1277, in certonly
le_client = _init_le_client(config, auth, installer)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 652, in _init_le_client
acc, acme = _determine_account(config)
File “/usr/lib/python2.7/site-packages/certbot/_internal/main.py”, line 570, in _determine_account
config, account_storage, tos_cb=_tos_cb)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 173, in register
acme = acme_from_config_key(config, key)
File “/usr/lib/python2.7/site-packages/certbot/_internal/client.py”, line 43, in acme_from_config_key
return acme_client.BackwardsCompatibleClientV2(net, key, config.server)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 831, in init
directory = messages.Directory.from_json(net.get(server).json())
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1168, in get
self._send_request(‘GET’, url, **kwargs), content_type=content_type)
File “/usr/lib/python2.7/site-packages/acme/client.py”, line 1118, in _send_request
response = self.session.request(method, url, *args, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 486, in request
resp = self.send(prep, **send_kwargs)
File “/usr/lib/python2.7/site-packages/requests/sessions.py”, line 598, in send
r = adapter.send(request, **kwargs)
File “/usr/lib/python2.7/site-packages/requests/adapters.py”, line 370, in send
timeout=timeout
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 544, in urlopen
body=body, headers=headers)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File “/usr/lib/python2.7/site-packages/urllib3/connectionpool.py”, line 314, in _raise_timeout
if ‘timed out’ in str(err) or ‘did not complete (read)’ in str(err): # Python 2.6
TypeError: str returned non-string (type Error)
2024-10-07 21:23:32,058:ERROR:certbot._internal.log:An unexpected error occurred:
2024-10-07 21:23:32,059:ERROR:certbot._internal.log:TypeError: str returned non-string (type Error)

Regards Yummiweb