fix: #297 - tls for mysql connetions
This commit is contained in:
parent
1c5a0099b6
commit
671c7e99a5
2
app.go
2
app.go
|
@ -748,7 +748,7 @@ func connectToDatabase(app *App) {
|
||||||
var db *sql.DB
|
var db *sql.DB
|
||||||
var err error
|
var err error
|
||||||
if app.cfg.Database.Type == driverMySQL {
|
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)
|
db.SetMaxOpenConns(50)
|
||||||
} else if app.cfg.Database.Type == driverSQLite {
|
} else if app.cfg.Database.Type == driverSQLite {
|
||||||
if !SQLiteEnabled {
|
if !SQLiteEnabled {
|
||||||
|
|
|
@ -9,6 +9,7 @@ password = changeme
|
||||||
database = writefreely
|
database = writefreely
|
||||||
host = db
|
host = db
|
||||||
port = 3306
|
port = 3306
|
||||||
|
tls = false
|
||||||
|
|
||||||
[app]
|
[app]
|
||||||
site_name = WriteFreely Example Blog!
|
site_name = WriteFreely Example Blog!
|
||||||
|
|
|
@ -57,6 +57,7 @@ type (
|
||||||
Database string `ini:"database"`
|
Database string `ini:"database"`
|
||||||
Host string `ini:"host"`
|
Host string `ini:"host"`
|
||||||
Port int `ini:"port"`
|
Port int `ini:"port"`
|
||||||
|
TLS bool `ini:"tls"`
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteAsOauthCfg struct {
|
WriteAsOauthCfg struct {
|
||||||
|
|
Loading…
Reference in New Issue