---
title: "Certificate verify failed from Cloud Run after a Cloud SQL server CA change | Proofline"
description: "If direct TCP connections from Cloud Run fail certificate verification, compare the CA file the revision pins with the instance's active server certificate."
url: https://proofline.sh/learn/cloud-sql-server-ca-rotation-cloud-run/
---

[Learning center](/learn/)

# Certificate verify failed from Cloud Run after a Cloud SQL server CA change

If direct TCP connections from Cloud Run fail certificate verification, compare the CA file the revision pins with the instance's active server certificate. A rotation or a CA mode change breaks only clients that verify against a stored CA; the Auth Proxy and the connectors fetch the current certificate themselves.

Security incidents The Proofline team November 23, 2026 6 min read

## Which clients a server CA change can break

Cloud SQL connections from Cloud Run take one of two kinds of path. The built-in Cloud SQL connection and the language connectors run through the Cloud SQL Auth Proxy or connector code, which encrypts the connection and verifies client and server identities automatically, whatever the instance's SSL mode. After a server CA rotation, Auth Proxy connections receive the new certificate when they connect. [Configure SSL/TLS](https://cloud.google.com/sql/docs/postgres/configure-ssl-instance#enforcing-ssl) · [Rotate server CA certificates](https://cloud.google.com/sql/docs/postgres/manage-ssl-instance#rotate)

A direct TCP connection to the instance's private or public IP is different. The driver uses whatever root certificate it was given, usually a `server-ca.pem` file baked into the image or mounted from a secret. In libpq, `sslmode=verify-ca` checks the server's certificate chain against that root, and `verify-full` also checks the host name against the certificate. With `sslmode=require`, libpq still verifies the CA if a root CA file is present, for backward compatibility. Any of these fails once the server presents a certificate the pinned file does not cover. [libpq SSL support](https://www.postgresql.org/docs/current/libpq-ssl.html)

Cloud SQL's troubleshooting page lists `Certificate verify failed.` among its connection errors, with client-certificate causes. A server-side CA change produces a verification failure of the same family, and drivers word it in their own way. The failure happens during the TLS handshake, before PostgreSQL checks the user, so it sits between stages 1 and 3 of the hub's [stage table](/learn/cloud-run-cloud-sql-connection-errors/#stage): the path worked and no login was attempted. [Troubleshooting](https://cloud.google.com/sql/docs/postgres/troubleshooting)

Three server-side changes produce it:

-   A rotation on an instance with a per-instance CA, `GOOGLE_MANAGED_INTERNAL_CA`, moves a new CA certificate from the "upcoming" slot to "active". Clients still pinning the old CA can no longer connect with SSL/TLS. [Roll back a rotation](https://cloud.google.com/sql/docs/postgres/manage-ssl-instance#rollback)
-   A change of `serverCaMode` to the shared CA, `GOOGLE_MANAGED_CAS_CA`, or a customer-managed CA replaces the per-instance CA with a regional hierarchy. With a shared CA, verifying the CA is not enough to verify the server, so Cloud SQL says the host name must be verified as well. [Server identity verification](https://cloud.google.com/sql/docs/postgres/configure-ssl-instance#server-identity-verification)
-   An expired server certificate fails every client that verifies the CA or the host name. Per-instance CA certificates last 10 years; shared and customer-managed CA server certificates last 1 year, and shorter for a customer-managed CA with a shorter validity. [Server certificates](https://cloud.google.com/sql/docs/postgres/configure-ssl-instance#server-certs)

## Check 1: what does the instance present now?

Read the CA mode and the rotation setting:

```
gcloud sql instances describe INSTANCE --project PROJECT \
  --format='yaml(settings.ipConfiguration.serverCaMode, settings.ipConfiguration.serverCertificateRotationMode, settings.ipConfiguration.sslMode, dnsNames)'
```

For a per-instance CA, list the server CA certificates; for a shared or customer-managed CA, list the server certificates. Each entry has a creation time, an expiry and a SHA-1 fingerprint, and the console labels them upcoming, active or previous. [List server certificates](https://cloud.google.com/sql/docs/postgres/configure-ssl-instance#server-cert-list-view) · [`server-ca-certs list`](https://cloud.google.com/sdk/gcloud/reference/sql/ssl/server-ca-certs/list) · [`server-certs list`](https://cloud.google.com/sdk/gcloud/reference/sql/ssl/server-certs/list)

```
gcloud sql ssl server-ca-certs list --instance INSTANCE --project PROJECT \
  --format='table(sha1Fingerprint, createTime, expirationTime)'

gcloud sql ssl server-certs list --instance INSTANCE --project PROJECT
```

Then find when it changed. For a per-instance CA, rotations are Admin Activity entries with the method `cloudsql.instances.rotateServerCa` and new CA certificates `cloudsql.instances.addServerCa`. An instance with a shared or customer-managed CA rotates through the API's `rotateServerCertificate` and `addServerCertificate` methods instead, which the audit logging page does not list, so the filter below matches both families by substring. A CA mode change is a settings change, `cloudsql.instances.update`. Each entry names the principal. [Cloud SQL audit logging](https://cloud.google.com/sql/docs/postgres/audit-logging) · [Instances API methods](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances) · [Manage server certificates](https://cloud.google.com/sql/docs/postgres/manage-ssl-instance)

```
gcloud logging read '
  logName="projects/PROJECT/logs/cloudaudit.googleapis.com%2Factivity"
  AND protoPayload.serviceName="cloudsql.googleapis.com"
  AND (protoPayload.methodName:"ServerCa" OR protoPayload.methodName:"ServerCertificate"
       OR protoPayload.methodName="cloudsql.instances.update")
  AND timestamp>="START_TIME"' \
  --project PROJECT --order=asc \
  --format='table(timestamp, protoPayload.methodName, protoPayload.authenticationInfo.principalEmail)'
```

With automatic server certificate rotation enabled on a shared or customer-managed CA, Cloud SQL rotates the server certificate during scheduled or self-service maintenance, up to 180 days before expiry. A failure that starts with a `MAINTENANCE` operation can be that rotation. [Automatic rotation](https://cloud.google.com/sql/docs/postgres/manage-ssl-instance#automatic-server-certificate-rotation-cas) · [Maintenance or deploy?](/learn/cloud-sql-maintenance-or-deploy/)

## Check 2: what does the revision trust?

Read the failing revision's connection settings: the host, the SSL mode and where the root certificate comes from. Then compute the fingerprint of the certificate the revision pins and compare it with the instance's list.

```
gcloud run revisions describe REVISION --project PROJECT --region REGION \
  --format='yaml(spec.containers[0].env, spec.volumes, metadata.annotations)'

openssl x509 -in server-ca.pem -noout -fingerprint -sha1
```

| Revision's path | Pinned certificate matches the active one | Reading |
| --- | --- | --- |
| Unix socket or connector | Not applicable | Not a pinned CA problem. The connector verifies with certificates it fetches; read the error stage again |
| Direct TCP, verify-ca, verify-full, or require with a root file | No, it matches "previous" | The rotation. Give the revision the current CA, or roll the rotation back while clients are updated |
| Direct TCP, verify-full | Yes, but the CA mode is now shared | The host name check: with a shared CA, connect to the DNS name in `dnsNames`, not the IP |
| Direct TCP, any verification | Yes, and nothing changed on the instance | The revision changed what it trusts or where it connects. Compare it with the previous revision |

## A worked fixture: one error, two changes

The fixture is illustrative. `orders-api` connects to `orders-db` over Direct VPC egress to its private IP, with `sslmode=verify-ca` and the root certificate file named by `PGSSLROOTCERT`, mounted from the secret `orders-db-ca`. `orders-api-00018` takes all traffic at 09:12:30 UTC, and its new instances fail certificate verification on every connection.

**Change A.** The audit log shows `cloudsql.instances.rotateServerCa` at 09:05:41 by `dba@example.com`. The server CA list:

| sha1Fingerprint | createTime | expirationTime |
| --- | --- | --- |
| `6c1f…e2` | 2026-11-16 | 2036-11-14 |
| `a94b…07` | 2024-03-02 | 2034-02-28 |

The secret holds `a94b…07`, now in the previous slot. `orders-api-00017` instances that connected before 09:05 kept their sessions, which is why nothing failed until new instances started. A new `orders-api-00017` instance started through its tag at 09:14 fails the same way. The deploy is not the cause. Add the new CA to the secret, or roll the rotation back until every client has it; rollback is possible only until the old certificate expires.

**Change B.** No rotation or update appears in the audit log, and the active certificate is the one in the secret. `orders-api-00018` mounts the secret at a new path, while `PGSSLROOTCERT`, the environment variable libpq reads for the root certificate file, still names the old path, where the image ships a CA file from an earlier instance. The deploy is the cause; fix the variable and redeploy. [libpq SSL support](https://www.postgresql.org/docs/current/libpq-ssl.html)

## Where the checks mislead

Open sessions survive a rotation. The server presents its certificate only during the handshake, so instances that connected before the change keep working, and the errors arrive with new instances: a deploy, a scale-out, or a pool replacing old connections. That timing points at the deploy and is usually misleading here.

Cloud Run's first-generation execution environment embeds Auth Proxy v1, which can only connect to instances with a per-instance CA. A CA mode change breaks those revisions too, even though they use the built-in connection. [Connect from Cloud Run](https://cloud.google.com/sql/docs/postgres/connect-run)

The instance's certificate list says what the server can present, not what each client trusts. A client may load roots from several places, such as the image's system store, a library default or an environment variable, so check what the driver actually loads in the running revision.

## Questions

### Do I need to update my Cloud Run service when Cloud SQL rotates its server CA?

Not if it connects through the built-in Cloud SQL connection or a Cloud SQL connector: they fetch the instance's certificate when they connect. A service that connects directly over TCP with a pinned CA file needs the new CA before the rotation completes.

### Why do only new Cloud Run instances fail after a CA rotation?

The certificate is checked when a connection is opened. Instances with connections opened before the rotation keep them; new instances and new connections meet the new certificate.

### What changes when a Cloud SQL instance moves to the shared CA?

The server certificate is issued by a regional CA shared across instances, valid for one year. Verifying the CA no longer identifies the instance, so clients must also verify the host name, using the instance's DNS name from `dnsNames`.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [A Cloud SQL SSL mode change rejects a Cloud Run client that used to connect](/learn/cloud-sql-ssl-mode-rejects-cloud-run/)
    
    Security incidents The Proofline team November 23, 2026 5 min read
    
-   ### [Cloud Run cannot reach Cloud SQL: revision, identity or connection?](/learn/cloud-run-cloud-sql-connection-errors/)
    
    Broken dependencies The Proofline team November 23, 2026 10 min read
