Postfix: ECDSA / RSA-Keys und TLS-Konfiguration

E-Mail-Server kommunizieren heute untereinander meist via TLS auf Basis von RSA-Keys. Nach dem Umzug meines E-Mail-Servers biete ich nun neben RSA ebenfalls auch einen ECC-Key für die Aushandlung einer TLS-Verbindung an.

Anbei meine aktuelle (Debian Stretch) Postfix-Konfiguration, mit der einerseits Abwärtskompatiblität gewährleistet wird, aber auch ECDSA parallel zu RSA zum Einsatz kommt:

/etc/postfix/main.cf

## Security
 # DH-Parameter
 smtpd_tls_dh1024_param_file = /etc/postfix/dh_4096.pem
 # TLS RSA keys path
 smtpd_tls_cert_file = /etc/ssl/certs/mail.kuketz.de.cer
 smtpd_tls_key_file = /etc/ssl/private/mail.kuketz.de.key
 # TLS ECDSA keys path
 smtpd_tls_eccert_file = /etc/ssl/certs/mail.kuketz.de_ecc.cer
 smtpd_tls_eckey_file = /etc/ssl/private/mail.kuketz.de_ecc.key
 # Enable additional Postfix SMTP server logging of TLS activity
 smtp_tls_loglevel = 1
 smtpd_tls_loglevel = 1
 # Uses TLS if this is supported by the receiving SMTP server / TLS policy for the destination is obtained via DNSSEC (Fallback to may)
 smtp_tls_security_level = dane
 # Uses TLS if this is supported by the sending SMTP server, otherwise use plaintext
 smtpd_tls_security_level = may
 # SSL/TLS protocols accepted by the Postfix SMTP client / Postfix SMTP server with TLS encryption
 smtp_tls_protocols = !SSLv2, !SSLv3
 smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
 smtpd_tls_protocols = !SSLv2, !SSLv3
 smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
 lmtp_tls_protocols = !SSLv2, !SSLv3
 lmtp_tls_mandatory_protocols = !SSLv2, !SSLv3
 # SSL/TLS supported ciphers
 smtp_tls_ciphers = high
 smtp_tls_mandatory_ciphers = high
 smtpd_tls_ciphers = high
 smtpd_tls_mandatory_ciphers = high
 tls_high_cipherlist = !aNULL:!eNULL:!CAMELLIA:HIGH:@STRENGTH
 # Prefer the servers order of ciphers over clients
 tls_preempt_cipherlist = yes
 # Server security grade for ephemeral elliptic-curve Diffie-Hellman (EECDH) key exchange
 smtpd_tls_eecdh_grade = ultra
 # No SSL compression
 tls_ssl_options = NO_COMPRESSION

## DNSSEC DNS-Lookups
 # Enable DNSSEC lookups
 smtp_dns_support_level = dnssec

Konfigurationseinstellungen zu Dovecot habe ich ausgelassen. Der oben dargestellte Code-Ausschnitt ist lediglich ein »Bausteine« für eine saubere Postfix TLS-Konfiguration.

Bevor ihr diese Konfiguration anwenden / ausrollen könnt sind ein paar Vorarbeiten notwendig:

1. DH-Key mit 4096 Bit erstellen:

openssl dhparam -out /etc/postfix/dh_4096.pem -2 4096

2. Und natürlich RSA, sowie ECDSA Private- und Public-Keys zu erstellen. Ich mache das mit acme.sh via Let’s Encrypt.

3. Einen DNSSEC kompatiblen DNS-Resolver wählen. Ist das nicht möglich, muss folgendes angepasst werden:

# Uses TLS if this is supported by the receiving SMTP server / TLS policy for the destination is obtained via DNSSEC (Fallback to may)
smtp_tls_security_level = may

[ENTFERNEN]## DNSSEC DNS-Lookups
# Enable DNSSEC lookups
smtp_dns_support_level = dnssec[ENTFERNEN]

(Offener) Streitpunkt:

In vielen (veralteten) Guides findet man ellenlange TLS-Ciphersuite Empfehlungen für Postfix mit einer Unmenge an Ausschlüssen. Ich finde, das geht eleganter:

tls_high_cipherlist = !aNULL:!eNULL:!CAMELLIA:HIGH:@STRENGTH

Wir schließen aus – OpenSSL Referenz:

  • aNULL: the cipher suites offering no authentication. (Damit schließen wir ebenfalls anonyme Cipher-Suiten aus)
  • eNULL: the „NULL“ ciphers that is those offering no encryption
  • CAMELLIA: Sicherheitsniveau relativ unbekannt.

Wir nehmen rein:

  • HIGH: „high“ encryption cipher suites. This currently means those with key lengths larger than 128 bits, and some cipher suites with 128-bit keys.
  • @STRENGTH: The cipher string @STRENGTH can be used at any point to sort the current cipher list in order of encryption algorithm key length.

Jetzt ist die Frage, weshalb nicht mehr Ausschlüsse (bspw. !SSLv3) notwendig sind in der Postfix Konfiguration? Weil wir bspw. Cipher-Suiten auf Basis von SSLv3 bereits unter »smtp_tls_protocols**« in der main.cf ausgeschlossen haben.

Die Konfiguration ergibt dann folgendes Ergebnis: Klick me!

Achtung: Es wird lediglich der ECC Key 384 Bit angezeigt. RSA funktioniert allerdings parallel, sofern der zu sendende / empfangende E-Mail-Server noch keine ECC-Keys unterstützt.

Das Ergebnis ist übrigens vergleichbar mit mailbox.org, die allerdings auch noch keine ECC-Keys unterstützen.

Hinweise zur Konfiguration und insbesondere zum Parameter »tls_high_cipherlist« nehme ich gerne per E-Mail entgegen.

Update: Mit testssl.sh habe ich jetzt auch mal geprüft, welche Cipher-Suiten (in welcher Reihenfolge) bevorzugt werden:

./testssl.sh -t=smtp mail.kuketz.de:25

Ergebnis:

Cipher order
TLSv1:     ECDHE-ECDSA-AES256-SHA ECDHE-RSA-AES256-SHA DHE-RSA-AES256-SHA AES256-SHA
               ECDHE-ECDSA-AES128-SHA ECDHE-RSA-AES128-SHA DHE-RSA-AES128-SHA AES128-SHA 
TLSv1.1:   ECDHE-ECDSA-AES256-SHA ECDHE-RSA-AES256-SHA DHE-RSA-AES256-SHA AES256-SHA
               ECDHE-ECDSA-AES128-SHA ECDHE-RSA-AES128-SHA DHE-RSA-AES128-SHA AES128-SHA 
TLSv1.2:   ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384
               DHE-RSA-AES256-GCM-SHA384 ECDHE-ECDSA-CHACHA20-POLY1305
               ECDHE-RSA-CHACHA20-POLY1305 DHE-RSA-CHACHA20-POLY1305 ECDHE-ECDSA-AES256-CCM8
               ECDHE-ECDSA-AES256-CCM DHE-RSA-AES256-CCM8 DHE-RSA-AES256-CCM
               ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES256-SHA256
               ECDHE-ECDSA-AES256-SHA ECDHE-RSA-AES256-SHA DHE-RSA-AES256-SHA
               AES256-GCM-SHA384 AES256-CCM8 AES256-CCM AES256-SHA256 AES256-SHA
               ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-GCM-SHA256
               DHE-RSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES128-CCM8 ECDHE-ECDSA-AES128-CCM
               DHE-RSA-AES128-CCM8 DHE-RSA-AES128-CCM ECDHE-ECDSA-AES128-SHA256
               ECDHE-RSA-AES128-SHA256 DHE-RSA-AES128-SHA256 ECDHE-ECDSA-AES128-SHA
               ECDHE-RSA-AES128-SHA DHE-RSA-AES128-SHA AES128-GCM-SHA256 AES128-CCM8
               AES128-CCM AES128-SHA256 AES128-SHA

Das bedeutet: ECDSA-Cipher werden vor RSA-Cipher bevorzugt. Genau wie ich das wollte. Daher halte ich den Parameter:

tls_high_cipherlist = !aNULL:!eNULL:!CAMELLIA:HIGH:@STRENGTH

für genau richtig auf Debian Stretch mit OpenSSL Version 1.1.0f Bibliothek.

Und einen ECDSA-Handshake mit einem anderen E-Mail-Server konnte ich nun ebenfalls beobachten:

Received: from vowogg.volkswohnung.com (mail.volkswohnung.com [109.109.203.162])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mail.kuketz.de (Postfix) with ESMTPS id C7D8260F9A
	for <mike@kuketz.de>; Fri, 23 Feb 2018 16:09:26 +0100 (CET)

Passt!

Der Kuketz-Blog ist spendenfinanziert! Mitmachen ➡