Skip to content

Commit

Permalink
fix: rely on the PSC DNS name instead of the private IP address (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
nancynh authored Jun 24, 2024
1 parent 0ee91b2 commit f4dd341
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,25 +333,13 @@ func (d *Dialer) Dial(ctx context.Context, instance string, opts ...DialOption)
}
}

// TODO: use the correct addr as server name once PSC DNS is populated
// in all existing clusters. When that happens, delete this if statement.
serverName := addr
if cfg.ipType == alloydb.PSC {
serverName, ok = ci.IPAddrs[alloydb.PrivateIP]
if !ok {
// This shouldn't happen, but be prudent regardless.
return nil, errtype.NewDialError(
"failed to lookup server name", inst.String(), nil,
)
}
}
c := &tls.Config{
Certificates: []tls.Certificate{ci.ClientCert},
RootCAs: ci.RootCAs,
// The PSC, private, and public IP all appear in the certificate as
// SAN. Use the server name that corresponds to the requested
// connection path.
ServerName: serverName,
ServerName: addr,
MinVersion: tls.VersionTLS13,
}
tlsConn := tls.Client(conn, c)
Expand Down

0 comments on commit f4dd341

Please sign in to comment.