Skip to content

Postfix SNI maps use incomplete certificate chain (cert.pem instead of fullchain.pem) #1175

@tromm

Description

@tromm

Description

When Virtualmin configures Postfix SNI maps for a domain with SSL enabled, it uses only the leaf certificate (ssl_cert, typically cert.pem) instead of the complete certificate chain (fullchain.pem). This causes mail clients to receive incomplete certificate chains, leading to certificate validation failures.

Impact

Mail clients (iOS Mail, Thunderbird, etc.) fail to validate the certificate because intermediate CAs are missing:

  • Clients cannot build the full chain to the root CA
  • Results in "certificate has expired" or "certificate is untrusted" errors
  • Affects SMTP-TLS and IMAP/POP3-TLS connections
  • Poor user experience for end-users
  • Security scanning services (e.g., Hardenized.com) report certificate chain errors

Root Cause

In /usr/share/webmin/virtual-server/feature-ssl.pl (line ~2887), the SNI map entry is built incorrectly. The code uses $d->{'ssl_cert'} which points to cert.pem (leaf certificate only) instead of the complete chain.

Current (wrong):
key + cert.pem

Expected (correct):
key + cert.pem + intermediate.pem

Or simply use fullchain.pem which includes all of these.

Steps to Reproduce

  1. Create a domain with SSL enabled and Let's Encrypt certificate
  2. Enable Postfix SNI support in Virtualmin
  3. Check /etc/postfix/sni_map - it will show domain.com pointing to cert.pem
  4. Send mail with mail client (eg iOS)
  5. Certificate validation fails because intermediates are missing

Evidence - Local Configuration

Current output (incorrect):
example.com /home/user/ssl_certificates/privkey.pem,/home/user/ssl_certificates/cert.pem

Should be:
example.com /home/user/ssl_certificates/privkey.pem,/home/user/ssl_certificates/fullchain.pem

Evidence - External Validation

Security scanning services report the incomplete certificate chain:

  • Hardenized.com reports: "Certificate chain incomplete - missing intermediate certificates"
  • SSL Labs / Qualys shows: "Chain incomplete" errors
  • testssl.sh reports: "Certificate chain order incorrect or incomplete"

Postfix SNI Map Requirement

According to Postfix documentation, the SNI map value should contain the complete chain:

  • Private key
  • Leaf certificate
  • Intermediate certificates (critical!)

Using only the leaf certificate violates this specification.

Suggested Fix

Replace in /usr/share/webmin/virtual-server/feature-ssl.pl around line 2887:

Old:

my @certs = ( $d->{'ssl_key'}, $d->{'ssl_cert'} );
push(@certs, $d->{'ssl_chain'}) if ($d->{'ssl_chain'});

New:

 my @certs = ( $d->{'ssl_key'}, $d->{'ssl_fullchain'} || $d->{'ssl_cert'} );
 push(@certs, $d->{'ssl_chain'}) if ($d->{'ssl_chain'});

Or use fullchain.pem path directly instead of cert.pem.

Environment

  • Virtualmin: 7.50.2.pro-1
  • Webmin: 2.610
  • Postfix: 3.4.13-0ubuntu1.4
  • Certbot: 3.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions