mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
MySQL TLS (#4642)
This commit is contained in:
parent
0dac1ff677
commit
127f477056
3 changed files with 12 additions and 8 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue