diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-12 13:40:11 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-12 13:40:11 +0800 |
commit | 3fec571183461c91a52a64f008cb0dacd194443d (patch) | |
tree | 16bd9325d2e24546f138b12ccce0940cb4a935a1 /config.go | |
parent | Use bufio.ReadWriter (diff) | |
download | maild-3fec571183461c91a52a64f008cb0dacd194443d.tar.gz maild-3fec571183461c91a52a64f008cb0dacd194443d.tar.zst maild-3fec571183461c91a52a64f008cb0dacd194443d.zip |
Add incoming STARTTLS support
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -2,6 +2,7 @@ package main import ( "bufio" + "crypto/tls" "os" "sync" @@ -15,6 +16,7 @@ var config struct { Cert string `scfg:"cert"` Key string `scfg:"key"` } `scfg:"tls"` + _tls_config *tls.Config } var config_mutex sync.RWMutex @@ -31,6 +33,14 @@ func load_config(path string) error { if err != nil { return err } + cer, err := tls.LoadX509KeyPair(config.TLS.Cert, config.TLS.Key) + if err != nil { + return err + } + config._tls_config = &tls.Config{ + Certificates: []tls.Certificate{cer}, + MinVersion: tls.VersionTLS13, + } return nil }() != nil { return err |