mirror of
https://github.com/decke/smtprelay.git
synced 2026-01-17 06:39:24 -07:00
Client certificate for relay
This commit is contained in:
committed by
Bernhard Fröhlich
parent
42d1721751
commit
0e352a9bb6
16
smtp.go
16
smtp.go
@@ -340,6 +340,14 @@ func SendMail(r *Remote, from string, to []string, msg []byte) error {
|
||||
ServerName: r.Hostname,
|
||||
InsecureSkipVerify: r.SkipVerify,
|
||||
}
|
||||
// Load client certificate on-demand, just before connection
|
||||
if r.ClientCertPath != "" && r.ClientKeyPath != "" {
|
||||
cert, err := tls.LoadX509KeyPair(r.ClientCertPath, r.ClientKeyPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
conn, err := tls.Dial("tcp", r.Addr, config)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -366,6 +374,14 @@ func SendMail(r *Remote, from string, to []string, msg []byte) error {
|
||||
ServerName: c.serverName,
|
||||
InsecureSkipVerify: r.SkipVerify,
|
||||
}
|
||||
// Load client certificate on-demand, just before use
|
||||
if r.ClientCertPath != "" && r.ClientKeyPath != "" {
|
||||
cert, err := tls.LoadX509KeyPair(r.ClientCertPath, r.ClientKeyPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
if testHookStartTLS != nil {
|
||||
testHookStartTLS(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user