Skip to content

Commit

Permalink
feat: Custom SAN Support (#902)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hessjcg authored Jan 6, 2025
1 parent 12c1618 commit 9339d75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cloudsql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *DNSInstanceConnectionNameResolver) queryDNS(ctx context.Context, domain
// Attempt to parse records, returning the first valid record.
for _, record := range records {
// Parse the target as a CN
cn, parseErr := instance.ParseConnName(record)
cn, parseErr := instance.ParseConnNameWithDomainName(record, domainName)
if parseErr != nil {
perr = fmt.Errorf("unable to parse TXT for %q -> %q : %v", domainName, record, parseErr)
continue
Expand Down
2 changes: 1 addition & 1 deletion internal/cloudsql/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *fakeResolver) LookupTXT(_ context.Context, name string) (addrs []string
}

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

r := DNSInstanceConnectionNameResolver{
dnsResolver: &fakeResolver{
Expand Down

0 comments on commit 9339d75

Please sign in to comment.