فهرست منبع

support SSL for waf

alteredCoder 1 سال پیش
والد
کامیت
0379574b14
1فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 9 1
      pkg/acquisition/modules/waf/waf.go

+ 9 - 1
pkg/acquisition/modules/waf/waf.go

@@ -45,6 +45,8 @@ type WafRunner struct {
 type WafSourceConfig struct {
 type WafSourceConfig struct {
 	ListenAddr                        string   `yaml:"listen_addr"`
 	ListenAddr                        string   `yaml:"listen_addr"`
 	ListenPort                        int      `yaml:"listen_port"`
 	ListenPort                        int      `yaml:"listen_port"`
+	CertFilePath                      string   `yaml:"cert_file"`
+	KeyFilePath                       string   `yaml:"key_file"`
 	Path                              string   `yaml:"path"`
 	Path                              string   `yaml:"path"`
 	WafRoutines                       int      `yaml:"waf_routines"`
 	WafRoutines                       int      `yaml:"waf_routines"`
 	Debug                             bool     `yaml:"debug"`
 	Debug                             bool     `yaml:"debug"`
@@ -315,7 +317,13 @@ func (w *WafSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb) err
 
 
 		w.logger.Infof("Starting WAF server on %s:%d%s", w.config.ListenAddr, w.config.ListenPort, w.config.Path)
 		w.logger.Infof("Starting WAF server on %s:%d%s", w.config.ListenAddr, w.config.ListenPort, w.config.Path)
 		t.Go(func() error {
 		t.Go(func() error {
-			err := w.server.ListenAndServe()
+			var err error
+			if w.config.CertFilePath != "" && w.config.KeyFilePath != "" {
+				err = w.server.ListenAndServeTLS(w.config.CertFilePath, w.config.KeyFilePath)
+			} else {
+				err = w.server.ListenAndServe()
+			}
+
 			if err != nil && err != http.ErrServerClosed {
 			if err != nil && err != http.ErrServerClosed {
 				return errors.Wrap(err, "WAF server failed")
 				return errors.Wrap(err, "WAF server failed")
 			}
 			}