Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use standard TLS hostname validation for instances with DNS names #954

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

hessjcg
Copy link
Contributor

@hessjcg hessjcg commented Mar 11, 2025

When the the Cloud SQL Instance reports that it has a DNS Name, the connector will use standard TLS hostname validation when checking the server certificate. Now, the server's TLS certificate must contain a SAN record with the instance's DNS name.

The ConnectSettings API added a field dns_names which contains all of the valid DNS names for
an instance.

Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small suggestion to add a comment, otherwise LGTM

Comment on lines +107 to +108
if dnm.Name != "" &&
dnm.ConnectionType == "PRIVATE_SERVICE_CONNECT" && dnm.DnsScope == "INSTANCE" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment here to explain this logic, especially since DnsScope may not be trivial

@hessjcg hessjcg requested a review from jackwotherspoon March 13, 2025 16:07
@jackwotherspoon
Copy link
Collaborator

@hessjcg looks like you re-requested a review here but my two nits still have not been addressed...

@hessjcg hessjcg force-pushed the cas-dns-names-field branch from 08c5e88 to c05654f Compare March 18, 2025 22:43
@hessjcg hessjcg force-pushed the cas-dns-names-field branch 2 times, most recently from 2228dc9 to 94492b7 Compare March 19, 2025 16:57
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hessjcg hessjcg force-pushed the cas-dns-names-field branch 3 times, most recently from ab9dbd7 to a97f945 Compare March 19, 2025 19:18
@hessjcg hessjcg changed the title refactor: Use new ConnectSettings.DnsNames field for TLS server name feat: Use standard TLS hostname validation for instances with DNS names Mar 19, 2025
Comment on lines 54 to 55
DNSName string
DNSNames []*sqladmin.DnsNameMapping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe a comment here explaining the two differences?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case an external contributor is trying to update tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@hessjcg hessjcg force-pushed the cas-dns-names-field branch 2 times, most recently from 7c953e0 to 3126f9a Compare March 19, 2025 19:42
…er certificate's server name.
@hessjcg hessjcg force-pushed the cas-dns-names-field branch from 3126f9a to c746d06 Compare March 19, 2025 19:45
@hessjcg hessjcg merged commit d733a16 into main Mar 19, 2025
14 checks passed
@hessjcg hessjcg deleted the cas-dns-names-field branch March 19, 2025 19:52
hessjcg added a commit to GoogleCloudPlatform/cloud-sql-jdbc-socket-factory that referenced this pull request Mar 19, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…es. (#2125)

When the Cloud SQL Instance reports that it has a DNS Name, the connector will use standard TLS hostname 
validation when checking the server certificate. Now, the server's TLS certificate must contain a SAN record 
with the instance's DNS name.

The ConnectSettings API added a field dns_names which contains all of the valid DNS names for
an instance.

See also GoogleCloudPlatform/cloud-sql-go-connector#954
hessjcg added a commit to GoogleCloudPlatform/cloud-sql-python-connector that referenced this pull request Mar 20, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…me of the instance. (#1242)

The Cloud SQL Instance ConnectSettings added a new field `dns_names` which contains a list of valid
DNS names for an instance. The Python Connector will use these DNS names, falling back to the old
`dns_name` field if `dns_names` is not populated. 

Other connectors use this DNS name for hostname validation for the instance's TLS server certificate. However, 
the python connector does not perform hostname validation due to limitations of python's TLS library. 
See also: GoogleCloudPlatform/cloud-sql-go-connector#954
hessjcg added a commit to GoogleCloudPlatform/cloud-sql-nodejs-connector that referenced this pull request Mar 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…es (#428)

When the the Cloud SQL Instance reports that it has a DNS Name, the connector will use standard TLS hostname validation when checking the server certificate. Now, the server's TLS certificate must contain a SAN record with the instance's DNS name.

The ConnectSettings API added a field dns_names which contains all of the valid DNS names for
an instance.

See also: GoogleCloudPlatform/cloud-sql-go-connector#954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants