mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Postgres: Allow disabling SNI on SSL-enabled connections (#83892)
* Postgres: Allow disabling SNI on SSL-enabled connections * Update docs/sources/setup-grafana/configure-grafana/_index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> --------- Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c2b94429e4
commit
22d8258e48
@@ -25,6 +25,7 @@ type DatabaseConfig struct {
|
||||
Pwd string
|
||||
Path string
|
||||
SslMode string
|
||||
SSLSNI string
|
||||
CaCertPath string
|
||||
ClientKeyPath string
|
||||
ClientCertPath string
|
||||
@@ -101,6 +102,7 @@ func (dbCfg *DatabaseConfig) readConfig(cfg *setting.Cfg) error {
|
||||
dbCfg.ConnMaxLifetime = sec.Key("conn_max_lifetime").MustInt(14400)
|
||||
|
||||
dbCfg.SslMode = sec.Key("ssl_mode").String()
|
||||
dbCfg.SSLSNI = sec.Key("ssl_sni").String()
|
||||
dbCfg.CaCertPath = sec.Key("ca_cert_path").String()
|
||||
dbCfg.ClientKeyPath = sec.Key("client_key_path").String()
|
||||
dbCfg.ClientCertPath = sec.Key("client_cert_path").String()
|
||||
@@ -168,12 +170,16 @@ func (dbCfg *DatabaseConfig) buildConnectionString(cfg *setting.Cfg, features fe
|
||||
|
||||
args := []any{dbCfg.User, addr.Host, addr.Port, dbCfg.Name, dbCfg.SslMode, dbCfg.ClientCertPath,
|
||||
dbCfg.ClientKeyPath, dbCfg.CaCertPath}
|
||||
|
||||
for i, arg := range args {
|
||||
if arg == "" {
|
||||
args[i] = "''"
|
||||
}
|
||||
}
|
||||
cnnstr = fmt.Sprintf("user=%s host=%s port=%s dbname=%s sslmode=%s sslcert=%s sslkey=%s sslrootcert=%s", args...)
|
||||
if dbCfg.SSLSNI != "" {
|
||||
cnnstr += fmt.Sprintf(" sslsni=%s", dbCfg.SSLSNI)
|
||||
}
|
||||
if dbCfg.Pwd != "" {
|
||||
cnnstr += fmt.Sprintf(" password=%s", dbCfg.Pwd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user