feat: FQDN-Support, IMAP-TLS und SMTP-TLS via Master-Cert

- config: IMAPServerConfig um TLSCert/TLSKey erweitert
- imapserver: TLS-Support (tls.Listen) mit automatischem Port 993-Default
- Server-Konfiguration: FQDN archivmail.scahome.local
  - nginx server_name auf archivmail.scahome.local gesetzt
  - SMTP domain auf archivmail.scahome.local
  - SMTP TLS aktiviert (/etc/ssl/archivmail/archivmail.crt)
  - IMAP-Server TLS auf Port 993 aktiviert
  - secure_cookies: true (HTTPS)
  - Firewall: Port 993 geöffnet
  - Zertifikat neu ausgestellt (SAN: archivmail.scahome.local + archivmail + 192.168.1.131)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-03-20 00:32:25 +01:00
parent 9e71af104f
commit 4a4136e4a6
2 changed files with 30 additions and 5 deletions
+27 -4
View File
@@ -9,6 +9,7 @@ package imapserver
import (
"bufio"
"context"
"crypto/tls"
"fmt"
"log/slog"
"net"
@@ -81,12 +82,34 @@ func New(
func (s *Server) Start() error {
bind := s.cfg.Bind
if bind == "" {
bind = "127.0.0.1:1143"
if s.cfg.TLSCert != "" {
bind = ":993"
} else {
bind = "127.0.0.1:1143"
}
}
ln, err := net.Listen("tcp", bind)
if err != nil {
return fmt.Errorf("imapserver: listen %s: %w", bind, err)
var ln net.Listener
var err error
if s.cfg.TLSCert != "" && s.cfg.TLSKey != "" {
cert, err := tls.LoadX509KeyPair(s.cfg.TLSCert, s.cfg.TLSKey)
if err != nil {
return fmt.Errorf("imapserver: load TLS cert: %w", err)
}
tlsCfg := &tls.Config{
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12,
}
ln, err = tls.Listen("tcp", bind, tlsCfg)
if err != nil {
return fmt.Errorf("imapserver: tls listen %s: %w", bind, err)
}
s.logger.Info("IMAP archive server TLS enabled", "addr", bind)
} else {
ln, err = net.Listen("tcp", bind)
if err != nil {
return fmt.Errorf("imapserver: listen %s: %w", bind, err)
}
}
s.mu.Lock()