aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-12 13:40:11 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-12 13:40:11 +0800
commit3fec571183461c91a52a64f008cb0dacd194443d (patch)
tree16bd9325d2e24546f138b12ccce0940cb4a935a1 /config.go
parentUse bufio.ReadWriter (diff)
downloadmaild-3fec571183461c91a52a64f008cb0dacd194443d.tar.gz
maild-3fec571183461c91a52a64f008cb0dacd194443d.tar.zst
maild-3fec571183461c91a52a64f008cb0dacd194443d.zip
Add incoming STARTTLS support
Diffstat (limited to '')
-rw-r--r--config.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/config.go b/config.go
index c76fa94..6605262 100644
--- a/config.go
+++ b/config.go
@@ -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