cloud-sql-proxy
                                
                                
                                
                                    cloud-sql-proxy copied to clipboard
                            
                            
                            
                        Failed to connect to Cloud SQL Instance with Google managed CAS certificate authority
Bug Description
- Create new Postgres Sql instance (I am using v16)
 - Default setting is now: 
GOOGLE_MANAGED_CAS_CA - Try to connect with cloud-sql-proxy it fails.
 
Example code (or command)
This fails when running CloudRun or running the cloud-sql-proxy.
./cloud-sql-proxy --address 0.0.0.0 --port 5555 huvrdata-testing:us-central1:testing-1
2025/05/05 14:32:22 Authorizing with Application Default Credentials
2025/05/05 14:32:22 [PROJECT-testing:us-central1:INSTANCE-1] Listening on [::]:5555
2025/05/05 14:32:22 The proxy has started successfully and is ready for new connections!
2025/05/06 13:57:31 [PROJECT-testing:us-central1:INSTANCE-1] accepted connection from 127.0.0.1:56966
2025/05/06 13:57:31 [PROJECT-testing:us-central1:INSTANCE-1] failed to connect to instance: Dial error: handshake failed (connection name = "PROJECT-testing:us-central1:INSTANCE-1"): Dial error: certificate had CN "", expected "PROJECT-testing:INSTANCE-1" (connection name = "PROJECT-testing:us-central1:INSTANCE-1")
This failure is caused by trying to run. psql connection.
psql --host 127.0.0.1 --port 5555 --user postgres --dbname dev --no-password --command 'SELECT COUNT(*) FROM assets_asset;'
The sql command is irrelevant.
I have two instances. The old instance works just fine. Works both with the local run and in Cloud Run.
Stacktrace
2025/05/06 13:57:31 [PROJECT-testing:us-central1:INSTANCE-1] failed to connect to instance: Dial error: handshake failed (connection name = "PROJECT-testing:us-central1:INSTANCE-1"): Dial error: certificate had CN "", expected "PROJECT-testing:INSTANCE-1" (connection name = "PROJECT-testing:us-central1:INSTANCE-1")
Steps to reproduce?
- Cloud Run connect to Cloud SQL
 - Add the connection
 - All DB connections fail to new instance
 
Cloud SQL instance has: GOOGLE_MANAGED_CAS_CA set.
Environment
- OS type and version: Locally running Mac, but CloudRun is my main concern
 - Cloud SQL Proxy version 
cloud-sql-proxy version 2.0.0 - Proxy invocation command: 
./cloud-sql-proxy --address 0.0.0.0 --port 5555 CONNECTION 
Additional Details
Related to: #2425 (similar errors)