aboutsummaryrefslogtreecommitdiffstats
path: root/models/models.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/models/models.go b/models/models.go
index 878e27e996..0123eab12d 100644
--- a/models/models.go
+++ b/models/models.go
@@ -155,7 +155,7 @@ func LoadConfigs() {
if len(DbCfg.Passwd) == 0 {
DbCfg.Passwd = sec.Key("PASSWD").String()
}
- DbCfg.SSLMode = sec.Key("SSL_MODE").String()
+ DbCfg.SSLMode = sec.Key("SSL_MODE").MustString("disable")
DbCfg.Path = sec.Key("PATH").MustString("data/gitea.db")
DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
@@ -222,13 +222,16 @@ func getEngine() (*xorm.Engine, error) {
}
switch DbCfg.Type {
case "mysql":
+ connType := "tcp"
if DbCfg.Host[0] == '/' { // looks like a unix socket
- connStr = fmt.Sprintf("%s:%s@unix(%s)/%s%scharset=utf8&parseTime=true",
- DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param)
- } else {
- connStr = fmt.Sprintf("%s:%s@tcp(%s)/%s%scharset=utf8&parseTime=true",
- DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param)
+ connType = "unix"
}
+ tls := DbCfg.SSLMode
+ if tls == "disable" { // allow (Postgres-inspired) default value to work in MySQL
+ tls = "false"
+ }
+ connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=utf8&parseTime=true&tls=%s",
+ DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, tls)
case "postgres":
connStr = getPostgreSQLConnectionString(DbCfg.Host, DbCfg.User, DbCfg.Passwd, DbCfg.Name, Param, DbCfg.SSLMode)
case "mssql":