Browse Source

enable basic TLS for mysql connection without server CA cert validation

pull/2501/head
Thorsten 9 years ago
parent
commit
bcf8b733b1
  1. 8
      models/models.go

8
models/models.go

@ -123,12 +123,16 @@ func getEngine() (*xorm.Engine, error) {
cnnstr := ""
switch DbCfg.Type {
case "mysql":
tls := ""
if DbCfg.SSLMode == "skip-verify" {
tls = "&tls=skip-verify";
}
if DbCfg.Host[0] == '/' { // looks like a unix socket
cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s?charset=utf8&parseTime=true",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
} else {
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=true",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=true%s",
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, tls)
}
case "postgres":
var host, port = "127.0.0.1", "5432"

Loading…
Cancel
Save