11package webircgateway
22
33import (
4+ "crypto/tls"
45 "errors"
56 "net"
67 "os"
@@ -27,6 +28,7 @@ type ConfigUpstream struct {
2728 ServerPassword string
2829 GatewayName string
2930 Proxy * ConfigProxy
31+ WebircCertificate []tls.Certificate
3032}
3133
3234// ConfigServer - A web server config
@@ -77,6 +79,7 @@ type Config struct {
7779 ReCaptchaSecret string
7880 ReCaptchaKey string
7981 Secret string
82+ WebircCert * tls.Certificate
8083 Plugins []string
8184 DnsblServers []string
8285 // DnsblAction - "deny" = deny the connection. "verify" = require verification
@@ -148,6 +151,7 @@ func (c *Config) Load() error {
148151 c .ReCaptchaKey = ""
149152 c .RequiresVerification = false
150153 c .Secret = ""
154+ c .WebircCert = nil
151155 c .SendQuitOnClientClose = ""
152156 c .ClientRealname = ""
153157 c .ClientUsername = ""
@@ -172,6 +176,20 @@ func (c *Config) Load() error {
172176 }
173177
174178 c .Secret = section .Key ("secret" ).MustString ("" )
179+
180+ // Load webirc client certificate
181+ webircCert := section .Key ("webirc_cert" ).MustString ("" )
182+ webircKey := section .Key ("webirc_key" ).MustString ("" )
183+ if webircCert != "" && webircKey != "" {
184+ certPath := c .ResolvePath (webircCert )
185+ keyPath := c .ResolvePath (webircKey )
186+ webircCert , err := tls .LoadX509KeyPair (certPath , keyPath )
187+ if err == nil {
188+ c .WebircCert = & webircCert
189+ } else {
190+ c .gateway .Log (3 , "Failed to load webirc certificate, " + err .Error ())
191+ }
192+ }
175193 c .SendQuitOnClientClose = section .Key ("send_quit_on_client_close" ).MustString ("Connection closed" )
176194 }
177195
0 commit comments