Skip to content

Commit

Permalink
feat: enable SNI (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Apr 2, 2024
1 parent 8a0397b commit 4071ffb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions driver/pgdriver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func parseDSN(dsn string) ([]Option, error) {
case "require":
if sslRootCert == "" {
tlsConfig.InsecureSkipVerify = true
tlsConfig.ServerName = u.Host
if host, _, err := net.SplitHostPort(u.Host); err == nil {
tlsConfig.ServerName = host
}
break
}
// For backwards compatibility reasons, in the presence of `sslrootcert`,
Expand All @@ -283,6 +287,10 @@ func parseDSN(dsn string) ([]Option, error) {
// (verify chain, but skip server name).
// See https://github.com/golang/go/issues/21971 .
tlsConfig.InsecureSkipVerify = true
tlsConfig.ServerName = u.Host
if host, _, err := net.SplitHostPort(u.Host); err == nil {
tlsConfig.ServerName = host
}
tlsConfig.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
certs := make([]*x509.Certificate, 0, len(rawCerts))
for _, rawCert := range rawCerts {
Expand Down

0 comments on commit 4071ffb

Please sign in to comment.