Dovecot-Probleme mit SSL-Zertifikat: Überprüfen Sie den Rückgabecode: 2 (Ausstellerzertifikat konnte nicht abgerufen werden)

Dovecot-Probleme mit SSL-Zertifikat: Überprüfen Sie den Rückgabecode: 2 (Ausstellerzertifikat konnte nicht abgerufen werden)

tut mir leid, aber ich bin ein Neuling bei SSL und was mache ich falsch? Ich versuche, die Dovecot-IMAP-Anmeldung in IMAPs zu ändern, aber bei der SSL-Zertifikatsprüfung läuft etwas schief. Das SSL-Zertifikat funktioniert für den HTTPS-Apache-Server und ist dasselbe, das ich für Dovecot zu verwenden versuche. Ich habe versucht, die Antwort von Dave Thomson zu verstehenhttps://stackoverflow.com/questions/47108886/openssl-s-client-error-verify-errornum-2unable-to-get-issuer-certificateaber für einen Neuling ist es schwer. Vielleicht kennst du einen einfacheren Weg. Danke und br

openssl s_client -connect <my-domain>:993 -servername <my-domain> -CAfile /etc/apache2/ssl/cert_2021.ca-bundle

Ausgabe:

CONNECTED(00000003)
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify error:num=2:unable to get issuer certificate
issuer= C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
issuer= C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=0 CN = <my-domain>
issuer= C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
---
Certificate chain
0 s:CN = <my-domain>
i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
---
Server certificate
-----BEGIN CERTIFICATE-----
...gJaprVUs
-----END CERTIFICATE-----
subject=CN = <my-domain>

issuer=C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA

---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 2192 bytes and written 397 bytes
Verification error: unable to get issuer certificate
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 2 (unable to get issuer certificate)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol  : TLSv1.3
Cipher    : TLS_AES_256_GCM_SHA384
Session-ID: 3B8DCD9A603FF577C1E77F40C5D3BCE2B9BAE026EF430566359B0D82353CE1E5
Session-ID-ctx:
Resumption PSK: 69E09...34D1
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 7200 (seconds)
TLS session ticket:
0000 - 97 86 ca 30 d9 1e 13 95-51 b3 06 87 9d 9f fe ec   ...0....Q.......
...
00d0 - 26 69 ba 7b 58 58 2c da-18 90 c9 8b 9f e2 3f be   &i.{XX,.......?.

Start Time: 1651046361
Timeout   : 7200 (sec)
Verify return code: 2 (unable to get issuer certificate)
Extended master secret: no
Max Early Data: 0
---
read R BLOCK
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol  : TLSv1.3
Cipher    : TLS_AES_256_GCM_SHA384
Session-ID: F834...EE6E
Session-ID-ctx:
Resumption PSK: A6FBE...23BF
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 7200 (seconds)
TLS session ticket:
0000 - 97 86 ca 30 d9 1e 13 95-51 b3 06 87 9d 9f fe ec   ...0....Q.......
...
00d0 - a9 74 d9 44 c8 40 43 11-48 32 1e e2 2a 8f b9 bb   [email protected]..*...

Start Time: 1651046361
Timeout   : 7200 (sec)
Verify return code: 2 (unable to get issuer certificate)
Extended master secret: no
Max Early Data: 0
---
read R BLOCK
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN] Dovecot (Raspbian) ready.
* BYE Disconnected for inactivity.
closed

für andere Versuche

openssl s_client -connect <my-domain>:993 -servername <my-domain> -CApath /etc/ssl/certs/ | grep 'returncode'

ich bekomme die gleiche Ausgabe:

depth=0 CN = <my-domain>
verify error:num=20:unable to get local issuer certificate
...
..
.
Start Time: 1651049986
Timeout   : 7200 (sec)
Verify return code: 21 (unable to verify the first certificate)
Extended master secret: no
Max Early Data: 0

Mein

/etc/dovecot/conf.d/10-ssl.conf

hat die minimale cfg

ssl = required
ssl_cert = </etc/apache2/ssl/cert_2021.crt
ssl_key = </etc/apache2/ssl/cert_2021.key
ssl_client_ca_file = /etc/apache2/ssl/cert_2021.ca-bundle
ssl_dh = </usr/share/dovecot/dh.pem

AKTUALISIEREN:

Nach Ihrer Eingabeanxich werfe das ganze Zeug in eine einzelne Datei. meine die crt-, key- und ca-bundle-Informationen schön und einfach mit copy + paste. gespeichert unter /etc/dovecot/privateohne symbolischen Link. unter /etc/dovecot/conf.d/10-ssl.confsetze ich

ssl_cert = </etc/dovecot/private/all_certs_in_one.txt
#ssl_client_ca_file = /etc/apache2/ssl/es_2021.ca-bundle

und ich habe den Befehl ausprobiert

openssl s_client -showcerts 6-connect <my-domain>:993 -servername <my-domain>

ich bekomme diese Ausgabe, die definitiv mehr ist als die letzte ...

CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 
322 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)
---

UPDATE - mit halber LÖSUNG

nano mkcert.sh

#!/bin/sh
# Generates a self-signed certificate.
# Edit dovecot-openssl.cnf before running this.
umask 077
OPENSSL=${OPENSSL-openssl}
SSLDIR=${SSLDIR-/etc/ssl}
OPENSSLCONFIG=${OPENSSLCONFIG-dovecot-openssl.cnf}

CERTDIR=$SSLDIR/certs
KEYDIR=$SSLDIR/private

CERTFILE=$CERTDIR/dovecot.pem
KEYFILE=$KEYDIR/dovecot.pem

if [ ! -d $CERTDIR ]; then
  echo "$SSLDIR/certs directory doesn't exist"
  exit 1
fi

if [ ! -d $KEYDIR ]; then
  echo "$SSLDIR/private directory doesn't exist"
  exit 1
fi

if [ -f $CERTFILE ]; then
  echo "$CERTFILE already exists, won't overwrite"
  exit 1
fi

if [ -f $KEYFILE ]; then
  echo "$KEYFILE already exists, won't overwrite"
  exit 1
fi

$OPENSSL req -new -x509 -nodes -config $OPENSSLCONFIG -out $CERTFILE -keyout $KEYFILE -days 3650 || exit 2
chmod 0600 $KEYFILE
echo
$OPENSSL x509 -subject -fingerprint -noout -in $CERTFILE || exit 2

nano dovecot-openssl.cnf

[ req ]
default_bits = 2048
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# country (2 letter code)
#C=FI

# State or Province Name (full name)
#ST=

# Locality Name (eg. city)
#L=Helsinki

# Organization (eg. company)
O=<MY FIRM NAME>

# Organizational Unit Name (eg. section)
OU=IMAP server

# Common Name (*.example.com is also possible)
CN=mail.<YOUR DOMAIN NAME>

# E-mail contact [email protected] 
emailAddress=support@<YOUR DOMAIN NAME>

[ cert_type ]
nsCertType = server

Symlinks erstellen:

ln -s /etc/ssl/certs/dovecot.pem /etc/dovecot/private/dovecot_pem_sym.pem
ln -s /etc/ssl/private/dovecot.pem /etc/dovecot/private/dovecot_pem_sym.key

nano /etc/dovecot/conf.d/10-ssl.conf

ssl = required
ssl_cert = </etc/dovecot/private/dovecot_pem_sym.pem
ssl_key = </etc/dovecot/private/dovecot_pem_sym.key
#ssl_client_ca_dir = /etc/ssl/certs
#ssl_client_ca_file =
#ssl_dh = </usr/share/dovecot/dh.pem 

Neustart

systemctl restart dovecot

prüfen

openssl s_client -showcerts -connect <YOUR mail.DOMAIN>:993 -servername <YOUR mail.DOMAIN>

Fehlercode ist

Verify return code: 18 (self signed certificate)

aber das ist besser als nichts =/ mein Apache-Zertifikat funktioniert nicht, aber ja. Es scheint, als könnten wir nicht alles zum Laufen bringen =(

methodbtw. nicht vergessen, in Outlook als Beispiel @cfg auf SSL/TLSnicht automatisch einzustellen

Antwort1

Wahrscheinlich haben Sie die ssl_client_ca_fileEinstellung versehentlich verwendet.Es wird verwendet, wenn Dovecot ausgehende Verbindungen in einemKlientRolle (wenn es beispielsweise um einen Proxy zu einem MTA/IMAP-Ziel geht, für das die Standard-CA des Systems ungeeignet ist). Dies ist völlig unabhängig von der Konfiguration von Dovecot, die eingehende Verbindungen in einemServerRolle, beispielsweise die Bereitstellung des IMAP-Dienstes über TLS.

Lassen Sie das ungesetzt und stattdessenVerketten Sie Ihre Server- und Zwischenzertifikatein eine kombinierte Datei zur Verwendung in ssl_cert=</path/to/file.

Beachten Sie die Reihenfolge, in Ihrem Fall wäre das vermutlich Ihr Serverzertifikat, dannSektigo, DannBenutzervertrauen. Da Sie derzeit auf von Apache2 verwendete Dateien verweisen, achten Sie darauf, keine Dateien zu ändern, die Sie anderswo konfiguriert haben (unter der Annahme, dass sie nur das Serverzertifikat oder die Kette enthalten).

verwandte Informationen