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: Support Private CA for server certificates. #408

Merged
merged 1 commit into from
Jan 10, 2025
Merged

Conversation

hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Dec 17, 2024

Support TLS validation on instances configured with a customer-managed private CA. Includes integration test.

@hessjcg hessjcg requested a review from a team as a code owner December 17, 2024 20:09
@hessjcg hessjcg force-pushed the customer-ca-support branch 4 times, most recently from 2bb7dde to eba701f Compare January 8, 2025 21:08
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.

Let's make sure to add the integration test to all 3 flavors: .ts, .mjs and .cjs files

@hessjcg hessjcg force-pushed the customer-ca-support branch 2 times, most recently from a39c7fb to 2724b5e Compare January 8, 2025 23:19
@hessjcg hessjcg changed the base branch from main to system-test-ts-only January 8, 2025 23:20
@hessjcg hessjcg force-pushed the customer-ca-support branch from 2724b5e to b3e86ef Compare January 8, 2025 23:21
@hessjcg
Copy link
Collaborator Author

hessjcg commented Jan 8, 2025

The mjs & cjs system tests are no longer required thanks to #412

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 ✅

@jackwotherspoon
Copy link
Collaborator

Looks like tests are not happy...

src/socket.ts Outdated
@@ -36,23 +36,26 @@ export function validateCertificate(
dnsName: string
) {
return (hostname: string, cert: tls.PeerCertificate): Error | undefined => {
if (serverCaMode === 'GOOGLE_MANAGED_CAS_CA') {
if (!serverCaMode || serverCaMode !== 'GOOGLE_MANAGED_INTERNAL_CA') {
Copy link
Collaborator

@jackwotherspoon jackwotherspoon Jan 9, 2025

Choose a reason for hiding this comment

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

i wonder if for this being undefined is causing issues potentially...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tests were failing due to a logic error. I fixed it: !serverCaMode || serverCaMode === 'GOOGLE_MANAGED_INTERNAL_CA'

test: Integration test for Customer Private CA CAS instance.
@hessjcg hessjcg force-pushed the customer-ca-support branch from 64a3d17 to c4a031c Compare January 10, 2025 17:18
@hessjcg hessjcg merged commit 36f1304 into main Jan 10, 2025
26 checks passed
@hessjcg hessjcg deleted the customer-ca-support branch January 10, 2025 17:23
hessjcg added a commit to GoogleCloudPlatform/cloud-sql-go-connector that referenced this pull request Jan 10, 2025
…om 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
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