[GELÖST] AH02572: Failed to configure at least one certificate and key

Debian macht sich hervorragend als Web- und Mailserver. Schau auch in den " Tipps und Tricks"-Bereich.
Antworten
Mpenzi
Beiträge: 65
Registriert: 26.07.2023 09:49:02

[GELÖST] AH02572: Failed to configure at least one certificate and key

Beitrag von Mpenzi » 08.08.2023 10:51:35

Hallo,
nach einem Dist-Upgrade (bullseye zu bookworm) bekomme ich auf dem Apache2-Server beim Aufruf von postfixadmin diese Webbrowser-Ausgabe:

Code: Alles auswählen

Fehlercode: SSL_ERROR_PROTOCOL_VERSION_ALERT
Das Let'sencrypt-Zertifikat existiert:

Code: Alles auswählen

certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: mx.example.com
    Serial Number: 4efdf8fb81729e22ce63a751e2f9a3e8ba3
    Key Type: RSA
    Domains:  mx.examlpe.com
    Expiry Date: 2023-10-03 22:49:08+00:00 (VALID: 56 days)
    Certificate Path: /etc/letsencrypt/live/mx.example.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/mx.example.com/privkey.pem
Die dazugehörige Apache2-Config sieht so aus:

Code: Alles auswählen

# postfixmail site configuration
# ! Do not remove this header !
#SSLStaplingCache "shmcb:logs/stapling-cache(150000)"

<VirtualHost *:80>
        ServerAdmin hostmaster@example.com
        ServerName mx.example.com
        ServerPath /
        Alias /postfixadmin/ /var/www/postfixadmin/public
        DocumentRoot "/var/www/postfixadmin/public"
 
        <Directory "/var/www/postfixadmin/public">
                Options -Indexes
                AllowOverride None
                Require all granted
        </Directory>

        <Files "setup.php">
                Options -Indexes
                AllowOverride None
                Require all granted
        </Files>        

        DirectoryIndex index.php

        ErrorLog ${APACHE_LOG_DIR}/postfixadmin_error.log
        CustomLog ${APACHE_LOG_DIR}/postfixadmin_access.log combined
 
        RewriteEngine on
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 
</VirtualHost>

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAdmin hostmaster@example.com
                ServerName mx.example.com
                ServerPath /
                Alias /postfixadmin/ /var/www/postfixadmin/public
                DocumentRoot "/var/www/postfixadmin/public"

                <Directory "/var/www/postfixadmin/public">
                        Options -Indexes
                        AllowOverride None
                        Require all granted
                </Directory>
        
                <Files "setup.php">
                        Options -Indexes
                        AllowOverride None
                        Require all granted
                </Files>
        
                DirectoryIndex index.php

                ErrorLog ${APACHE_LOG_DIR}/postfixadmin_error.log
                CustomLog ${APACHE_LOG_DIR}/postfixadmin_access.log combined

                TraceEnable off
                AddDefaultCharset utf-8

                SSLEngine on
                SSLProtocol -ALL +TLSv1
                SSLCipherSuite EECDH+AES256:DHE+AES256:EECDH+AES:EDH+AES:-SHA1:EECDH+RC4:EDH+RC4:RC4-SHA:AES256-SHA:!aNULL:!eNULL:!EXP:!LOW:!MD5
                SSLHonorCipherOrder on
                SSLCertificateFile /etc/letsencrypt/live/mx.example.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/mx.example.com/privkey.pem

                <Files "config.php">
                        Options +FollowSymLinks
                        Require host example.com
                </Files>

                <Location /rspamd>
                        Require all granted
                </Location>

                RewriteEngine On
                RewriteRule ^/rspamd$ /rspamd/ [R,L]
                RewriteRule ^/rspamd/(.*) http://127.0.0.1:11334/$1 [P]

        </VirtualHost>

</IfModule>
Also ich bekomme den Apache zwar zum Laufen, aber das SSL funktioniert nicht mehr wie gewünscht. Zertifikat ist installiert und Abschalten von SSL wäre keine sinnvolle Option.
Im Moment weiß ich nicht weiter. Vielleicht ihr?

Viele Grüße
MPenzi

Code: Alles auswählen

apachectl configtest
Syntax OK

Code: Alles auswählen

systemctl status apache2.service -l --no-pager
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running) since Tue 2023-08-08 10:33:09 CEST; 12min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 9661 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 9665 (apache2)
      Tasks: 7 (limit: 9481)
     Memory: 18.7M
        CPU: 172ms
     CGroup: /system.slice/apache2.service
             ├─ 9665 /usr/sbin/apache2 -k start
             ├─ 9666 /usr/sbin/apache2 -k start
             ├─ 9667 /usr/sbin/apache2 -k start
             ├─ 9668 /usr/sbin/apache2 -k start
             ├─ 9669 /usr/sbin/apache2 -k start
             ├─ 9670 /usr/sbin/apache2 -k start
             └─10957 /usr/sbin/apache2 -k start

Aug 08 10:33:09 mx systemd[1]: Starting apache2.service - The Apache HTTP Server...
Aug 08 10:33:09 mx systemd[1]: Started apache2.service - The Apache HTTP Server.

Code: Alles auswählen

# grep AH02572 /var/log/apache2/postfixadmin_error.log
[Tue Aug 08 09:51:10.259989 2023] [ssl:emerg] [pid 5842] AH02572: Failed to configure at least one certificate and key for mx.example.com:443
[Tue Aug 08 09:51:33.226621 2023] [ssl:emerg] [pid 5881] AH02572: Failed to configure at least one certificate and key for mx.example.com:443
[Tue Aug 08 10:13:01.364900 2023] [ssl:emerg] [pid 7811] AH02572: Failed to configure at least one certificate and key for mx.example.com:443

Code: Alles auswählen

# apache2ctl -M | grep ssl
 ssl_module (shared)
Zuletzt geändert von Mpenzi am 09.08.2023 08:18:19, insgesamt 1-mal geändert.

Mpenzi
Beiträge: 65
Registriert: 26.07.2023 09:49:02

Re: AH02572: Failed to configure at least one certificate and key

Beitrag von Mpenzi » 08.08.2023 18:53:02

Ich habe vielleicht das Problem gefunden:

Code: Alles auswählen

echo | openssl s_client -connect mx.example.com -port 143
CONNECTED(00000003)
40A75A039A7F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:354:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 5 bytes and written 320 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
"ssl3_get_record:wrong version number" scheint das Problem zu sein.

Benutzeravatar
oln
Beiträge: 487
Registriert: 05.01.2021 09:41:24

Re: AH02572: Failed to configure at least one certificate and key

Beitrag von oln » 09.08.2023 07:36:50

Moin,
ich glaube nicht, dass das etwas mit deinem Apache-Problem zu tun hat.
Nimm doch mal diese drei Zeilen raus:

Code: Alles auswählen

SSLProtocol -ALL +TLSv1
SSLCipherSuite EECDH+AES256:DHE+AES256:EECDH+AES:EDH+AES:-SHA1:EECDH+RC4:EDH+RC4:RC4-SHA:AES256-SHA:!aNULL:!eNULL:!EXP:!LOW:!MD5
SSLHonorCipherOrder on
PS:
Du gehtst auf den IMAP-Port der unverschlüsselt ist. Eigentlich solltest du auf 993 gehen.
Gruß Ole
AbuseIPDB

Mpenzi
Beiträge: 65
Registriert: 26.07.2023 09:49:02

Re: AH02572: Failed to configure at least one certificate and key

Beitrag von Mpenzi » 09.08.2023 08:18:00

Hallo Ole,

stimmt ohne diese Zeilen funktioniert es es wieder.
oln hat geschrieben: ↑ zum Beitrag ↑
09.08.2023 07:36:50
Nimm doch mal diese drei Zeilen raus:

Code: Alles auswählen

SSLProtocol -ALL +TLSv1
SSLCipherSuite EECDH+AES256:DHE+AES256:EECDH+AES:EDH+AES:-SHA1:EECDH+RC4:EDH+RC4:RC4-SHA:AES256-SHA:!aNULL:!eNULL:!EXP:!LOW:!MD5
SSLHonorCipherOrder on
Allerdings waren diese bei Bullseye auch schon drin und wurden ja nicht durch das Dist-Upgrade rein geschrieben. Also ist bei Bookworm an dieser Stelle etwas anders und die Frage ist was. Nicht, dass das eine Rolle in diesem Fall gerade spielt, da ja es wieder funktioniert. Aber andere brauchen diese Zeilen eventuell und haben das gleiche Problem.
oln hat geschrieben: ↑ zum Beitrag ↑
09.08.2023 07:36:50
PS:
Du gehtst auf den IMAP-Port der unverschlüsselt ist. Eigentlich solltest du auf 993 gehen.
Stimmt, da habe ich nicht gedacht. Aber das ist ein Mailserver, der die gleichen Zertifikate für Mail- und Webserver hat. Ein Ausfall des Mailservers wäre fataler gewesen als das Browserverwaltungstool für die Mailadressen.

Vielen Dank für den Hinweise,

MPenzi

Benutzeravatar
oln
Beiträge: 487
Registriert: 05.01.2021 09:41:24

Re: AH02572: Failed to configure at least one certificate and key

Beitrag von oln » 09.08.2023 09:57:59

Mpenzi hat geschrieben: ↑ zum Beitrag ↑
09.08.2023 08:18:00
Allerdings waren diese bei Bullseye auch schon drin und wurden ja nicht durch das Dist-Upgrade rein geschrieben. Also ist bei Bookworm an dieser Stelle etwas anders und die Frage ist was. Nicht, dass das eine Rolle in diesem Fall gerade spielt, da ja es wieder funktioniert. Aber andere brauchen diese Zeilen eventuell und haben das gleiche Problem.
Wenn du eine starke Verschlüsselung forderst, solltest du vorher schauen, was dein Apache überhaupt kann.

Code: Alles auswählen

curl -vv -k https://test.example.com
Danach kannst du dann dein SSLProtokoll auswählen. Generell solltest du dich mit Apache hardening auseinander setzen.
Gruß Ole
AbuseIPDB

Mpenzi
Beiträge: 65
Registriert: 26.07.2023 09:49:02

Re: AH02572: Failed to configure at least one certificate and key

Beitrag von Mpenzi » 09.08.2023 10:14:10

oln hat geschrieben: ↑ zum Beitrag ↑
09.08.2023 09:57:59
Wenn du eine starke Verschlüsselung forderst, solltest du vorher schauen, was dein Apache überhaupt kann.

Code: Alles auswählen

curl -vv -k https://test.example.com
Danach kannst du dann dein SSLProtokoll auswählen. Generell solltest du dich mit Apache hardening auseinander setzen.
Danke für die Information. Mit TSLv1.3 hätte der auch keine Probleme:

Code: Alles auswählen

curl -vv -k https://mx.example.com
*   Trying 192.106.240.70:443...
* Connected to mx.example.com (192.106.240.70) port 443 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: CN=mx.example.com
*  start date: Jul  5 22:49:09 2023 GMT
*  expire date: Oct  3 22:49:08 2023 GMT
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* using HTTP/1.1
> GET / HTTP/1.1
> Host: mx.example.com
> User-Agent: curl/7.88.1
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/1.1 302 Found
< Date: Wed, 09 Aug 2023 08:11:25 GMT
< Server: Apache/2.4.57 (Debian)
< Location: login.php
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< 
* Connection #0 to host mx.example.com left intact

Antworten