Skip to content

Commit f4dd341

Browse files
authored
fix: rely on the PSC DNS name instead of the private IP address (#590)
1 parent 0ee91b2 commit f4dd341

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

dialer.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,25 +333,13 @@ func (d *Dialer) Dial(ctx context.Context, instance string, opts ...DialOption)
333333
}
334334
}
335335

336-
// TODO: use the correct addr as server name once PSC DNS is populated
337-
// in all existing clusters. When that happens, delete this if statement.
338-
serverName := addr
339-
if cfg.ipType == alloydb.PSC {
340-
serverName, ok = ci.IPAddrs[alloydb.PrivateIP]
341-
if !ok {
342-
// This shouldn't happen, but be prudent regardless.
343-
return nil, errtype.NewDialError(
344-
"failed to lookup server name", inst.String(), nil,
345-
)
346-
}
347-
}
348336
c := &tls.Config{
349337
Certificates: []tls.Certificate{ci.ClientCert},
350338
RootCAs: ci.RootCAs,
351339
// The PSC, private, and public IP all appear in the certificate as
352340
// SAN. Use the server name that corresponds to the requested
353341
// connection path.
354-
ServerName: serverName,
342+
ServerName: addr,
355343
MinVersion: tls.VersionTLS13,
356344
}
357345
tlsConn := tls.Client(conn, c)

0 commit comments

Comments
 (0)