From 671c7e99a5b97ef8b3dc95e2ea6daa52458130b9 Mon Sep 17 00:00:00 2001 From: "Joice M. Joseph" Date: Thu, 16 Apr 2020 09:34:16 +0530 Subject: [PATCH] fix: #297 - tls for mysql connetions --- app.go | 2 +- config.ini.example | 1 + config/config.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index ca92192..fa7dfae 100644 --- a/app.go +++ b/app.go @@ -748,7 +748,7 @@ func connectToDatabase(app *App) { var db *sql.DB var err error if app.cfg.Database.Type == driverMySQL { - db, err = sql.Open(app.cfg.Database.Type, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()))) + db, err = sql.Open(app.cfg.Database.Type, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=%s&tls=%t", app.cfg.Database.User, app.cfg.Database.Password, app.cfg.Database.Host, app.cfg.Database.Port, app.cfg.Database.Database, url.QueryEscape(time.Local.String()), app.cfg.Database.TLS)) db.SetMaxOpenConns(50) } else if app.cfg.Database.Type == driverSQLite { if !SQLiteEnabled { diff --git a/config.ini.example b/config.ini.example index 7ac944e..8b74ddc 100644 --- a/config.ini.example +++ b/config.ini.example @@ -9,6 +9,7 @@ password = changeme database = writefreely host = db port = 3306 +tls = false [app] site_name = WriteFreely Example Blog! diff --git a/config/config.go b/config/config.go index 520dd59..58dfbd3 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,7 @@ type ( Database string `ini:"database"` Host string `ini:"host"` Port int `ini:"port"` + TLS bool `ini:"tls"` } WriteAsOauthCfg struct {