Can not renew my LE certificate! Why?

Well, I only promoted the www address for my NextCloud.
I initially understood it wrong and thought certs cannot contain www, so I started without and corrected it afterwards. The www worked for me all the years.

Anyway, let's try to fix this.

The output of sudo certbot certificates:

Found the following certs:
  Certificate Name: woestmeyer.com
    Serial Number: 3f2f51356e3aa765d3f097d282332132fb9
    Key Type: RSA
    Domains: woestmeyer.com
    Expiry Date: 2023-08-05 05:20:18+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/woestmeyer.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/woestmeyer.com/privkey.pem
  Certificate Name: www.woestmeyer.com
    Serial Number: 3ac936a6ee5ee8f880b0c610c092a37ecdc
    Key Type: RSA
    Domains: www.woestmeyer.com
    Expiry Date: 2023-08-05 05:27:27+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/www.woestmeyer.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/www.woestmeyer.com/privkey.pem

contents of: /etc/apache2/sites-enabled/000-default-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf

ServerName www.woestmeyer.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/www.woestmeyer.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.woestmeyer.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
<IfModule mod_headers.c>
 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
</VirtualHost>
</IfModule>

Okay, that way?
/var/www/html is my NC installation.

If you don't use that name then you should delete that cert

sudo certbot delete --cert-name woestmeyer.com

After doing that, is this successful?

sudo certbot renew --dry-run
3 Likes
Processing /etc/letsencrypt/renewal/www.woestmeyer.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for www.woestmeyer.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
  /etc/letsencrypt/live/www.woestmeyer.com/fullchain.pem (success)

Yes! Deleted the unused one.
The site now comes up with:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

I think, the logs are the NC logs to look up, right?

Yes, the certs look fine now. They are renewing successfully and connections to your www domain use the current cert. Note you have an IP address in the DNS for your root name so requests can be made to that name. And, HTTPS requests fail due to mis-matched domain name but if you don't care I don't care :slight_smile:

The HTTP 500 error is not related to the certs. I didn't see anything in your Apache config that causes that. But, what is in this folder?

ls -l /etc/apache2/sites-enabled/

Also, did you change anything in your base Apache config recently?

3 Likes
lrwxrwxrwx 1 root root   35 Sep 16  2018       000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root   52 Sep 16  2018       000-default-le-ssl.conf -> /etc/apache2/sites-available/000-default-le-ssl.conf
-rw-r--r-- 1 root root 1790 Okt 22  2019          000-default-le-ssl.conf.save

I noticed some apache2 updates recently, which I enrolled certainly - mostly automatically.

What is in that file? And do you know if your base Apache config would include a file with a .save extension?

3 Likes

I contains mostly the same as the conf without the *.save extension , see above.

Unfortunately not. If, then I made this long time ago. Or edited it, due to new config requirements of NC.

<IfModule mod_ssl.c>
<VirtualHost *:443>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf

ServerName www.woestmeyer.com
SSLCertificateFile /etc/letsencrypt/live/www.woestmeyer.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.woestmeyer.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
<IfModule mod_headers.c>
 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
</VirtualHost>
</IfModule>

<IfModule mod_headers.c>
 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomai>
</IfModule>

Just to be safe you should move that .save file to your /sites-available/ folder or somewhere else if you still need it.

As for the http 500, you should see some errors in the Apache error logs. It is also affecting just HTTP requests to your root domain so is not cert related. Something must be in your base Apache config that is causing this.

I know you don't care about the root name requests but this just helps locate the problem.

It is a little odd that the Strict-Transport-Security header is set for this HTTP request. Normally that is only used for HTTPS requests so maybe this is a clue on what to look at in your Apache config.

curl -I http://woestmeyer.com
HTTP/1.1 500 Internal Server Error
Date: Sun, 07 May 2023 14:42:29 GMT
Server: Apache/2.4.52 (Ubuntu)
Strict-Transport-Security: max-age=15768000; preload
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Upgrade: h2,h2c
Connection: Upgrade, close
Content-Type: text/plain; charset=utf-8
4 Likes

Do you think I should better start over with my NC installation?

As it's only for private use, it's no really a big deal. It has several odd configuration changes and additions over the years, that I did not track by 100 %.

I don't know NC well enough to say.

4 Likes

Guess what, I'll do that. A fresh start once in awhile can do wonders. Tracking back old errors is a waste of time.

Now I understand it much more than in 2018, and the installation / updating is not a nightmare anymore.
When there's another problem with the certs, I'll be back here.

Thank you for your help, every1 & your patience!

2 Likes

It still isn't :frowning:
The file has several opens with no matching closings.

2 Likes

Anyway.
I made it all new today. About an hour of work.
The process of certification worked like a charme. So, I'm all good (again) now!

1 Like

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