Skip to content

Commit 9339d75

Browse files
authored
feat: Custom SAN Support (#902)
The DNS Resolver should return a ConnName with the resolved instance name and the DNS name. This will ensure that the cache key is correct, and it will allow the TLS connections to use the domain name to validate the TLS server certificate.
1 parent 12c1618 commit 9339d75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/cloudsql/resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (r *DNSInstanceConnectionNameResolver) queryDNS(ctx context.Context, domain
105105
// Attempt to parse records, returning the first valid record.
106106
for _, record := range records {
107107
// Parse the target as a CN
108-
cn, parseErr := instance.ParseConnName(record)
108+
cn, parseErr := instance.ParseConnNameWithDomainName(record, domainName)
109109
if parseErr != nil {
110110
perr = fmt.Errorf("unable to parse TXT for %q -> %q : %v", domainName, record, parseErr)
111111
continue

internal/cloudsql/resolver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (r *fakeResolver) LookupTXT(_ context.Context, name string) (addrs []string
3636
}
3737

3838
func TestDNSInstanceNameResolver_Lookup_Success_TxtRecord(t *testing.T) {
39-
want, _ := instance.ParseConnName("my-project:my-region:my-instance")
39+
want, _ := instance.ParseConnNameWithDomainName("my-project:my-region:my-instance", "db.example.com")
4040

4141
r := DNSInstanceConnectionNameResolver{
4242
dnsResolver: &fakeResolver{

0 commit comments

Comments
 (0)