[v10.3.x] Postgres: Allow disabling SNI on SSL-enabled connections (#84259)

* 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>
(cherry picked from commit 22d8258e48)

* Adjust SNI test
This commit is contained in:
Sofia Papagiannaki
2024-03-20 17:26:39 +02:00
committed by GitHub
parent 423b47df74
commit cd81c5e4f9
5 changed files with 95 additions and 0 deletions
+6
View File
@@ -318,12 +318,16 @@ func (ss *SQLStore) buildConnectionString() (string, error) {
args := []any{ss.dbCfg.User, addr.Host, addr.Port, ss.dbCfg.Name, ss.dbCfg.SslMode, ss.dbCfg.ClientCertPath,
ss.dbCfg.ClientKeyPath, ss.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 ss.dbCfg.SSLSNI != "" {
cnnstr += fmt.Sprintf(" sslsni=%s", ss.dbCfg.SSLSNI)
}
if ss.dbCfg.Pwd != "" {
cnnstr += fmt.Sprintf(" password=%s", ss.dbCfg.Pwd)
}
@@ -498,6 +502,7 @@ func (ss *SQLStore) readConfig() error {
ss.dbCfg.ConnMaxLifetime = sec.Key("conn_max_lifetime").MustInt(14400)
ss.dbCfg.SslMode = sec.Key("ssl_mode").String()
ss.dbCfg.SSLSNI = sec.Key("ssl_sni").String()
ss.dbCfg.CaCertPath = sec.Key("ca_cert_path").String()
ss.dbCfg.ClientKeyPath = sec.Key("client_key_path").String()
ss.dbCfg.ClientCertPath = sec.Key("client_cert_path").String()
@@ -780,6 +785,7 @@ type DatabaseConfig struct {
Pwd string
Path string
SslMode string
SSLSNI string
CaCertPath string
ClientKeyPath string
ClientCertPath string