Skip to content

feat: Update TLS validation to use both SAN and CN fields.#2150

Merged
hessjcg merged 1 commit intomainfrom
feat-new-tls-logic
Apr 28, 2025
Merged

feat: Update TLS validation to use both SAN and CN fields.#2150
hessjcg merged 1 commit intomainfrom
feat-new-tls-logic

Conversation

@hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Apr 23, 2025

This updates the logic used by the connector to validate server certificates.
When connecting to the instance, the connector's TLS validator will first check the SAN field,
and then if that fails check the CN field in the certificate for the instance name. This will enable
the connector to work smoothly with both legacy and newer instances.

To summarize the deviations from standard TLS hostname verification:

Historically, Cloud SQL creates server certificates with the instance name in the Subject.CN field in
the format "my-project:my-instance". The connector is expected to check that the instance name
that the connector was configured to dial matches the server certificate Subject.CN field. Thus,
the Subject.CN field for most Cloud SQL instances does not contain a well-formed DNS Name. This
breaks standard TLS hostname verification.

Also, there are times when the instance metadata reports that an instance has a DNS name, but
that DNS name does not yet appear in the SAN records of the server certificate. The client should
fall back to validating the hostname using the instance name in the Subject.CN field.

See also: GoogleCloudPlatform/cloud-sql-go-connector#979

@hessjcg hessjcg requested a review from a team as a code owner April 23, 2025 19:37
@hessjcg hessjcg force-pushed the feat-new-tls-logic branch from 7d1a95c to 1e93513 Compare April 25, 2025 14:57
@hessjcg hessjcg merged commit e7d9cef into main Apr 28, 2025
18 checks passed
@hessjcg hessjcg deleted the feat-new-tls-logic branch April 28, 2025 17:00
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.

2 participants

Comments