Skip to content

Commit e88d82a

Browse files
authored
chore: Simplify server cert validation logic to distinguish legacy from CA validation (#910)
Going forward, both GOOGLE_MANAGED_CAS_CA, CUSTOMER_MANAGED_CAS_CA, and future new kinds of CA will use standard TLS domain name validation using the server certificate SAN records. The certificate validation logic for the original GOOGLE_MANAGED_INTERNAL_CA is now the exception. See implementation in other connectors: feat: Support Private CA for server certificates. GoogleCloudPlatform/cloud-sql-nodejs-connector#408 feat: Support Customer CAS Private CA for server certificates. GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#2095
1 parent 3e8203a commit e88d82a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/cloudsql/instance.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,17 @@ func (c ConnectionInfo) TLSConfig() *tls.Config {
241241
for _, caCert := range c.ServerCACert {
242242
pool.AddCert(caCert)
243243
}
244-
if c.ServerCAMode == "GOOGLE_MANAGED_CAS_CA" ||
245-
c.ServerCAMode == "CUSTOMER_MANAGED_CAS_CA" {
246-
// For CAS instances, we can rely on the DNS name to verify the server identity.
244+
if c.ServerCAMode != "" && c.ServerCAMode != "GOOGLE_MANAGED_INTERNAL_CA" {
245+
// By default, use Standard TLS hostname verification name to
246+
// verify the server identity.
247247
return &tls.Config{
248248
ServerName: c.DNSName,
249249
Certificates: []tls.Certificate{c.ClientCertificate},
250250
RootCAs: pool,
251251
MinVersion: tls.VersionTLS13,
252252
}
253253
}
254+
// For legacy instances use the custom TLS validation
254255
return &tls.Config{
255256
ServerName: c.ConnectionName.String(),
256257
Certificates: []tls.Certificate{c.ClientCertificate},

0 commit comments

Comments
 (0)