Postgres SSL Enforcement
Your Supabase project supports connecting to the Postgres DB without SSL enabled to maximize client compatibility. For increased security, you can prevent clients from connecting if they're not using SSL.
Disabling SSL enforcement only applies to connections to Postgres and Supavisor ("Connection Pooler"); all HTTP APIs offered by Supabase (e.g., PostgREST, Storage, Auth) automatically enforce SSL on all incoming connections.
Projects need to be at least on Postgres 13.3.0 to enable SSL enforcement. You can find the Postgres version of your project in the Infrastructure Settings page. If your project is on an older version, you will need to upgrade to use this feature.
Manage SSL enforcement via the dashboard
SSL enforcement can be configured via the "Enforce SSL on incoming connections" setting under the SSL Configuration section in Database Settings page of the dashboard.
Manage SSL enforcement via the CLI
To get started:
- Install the Supabase CLI 1.37.0+.
- Log in to your Supabase account using the CLI.
- Ensure that you have Owner or Admin permissions for the project that you are enabling SSL enforcement.
Check enforcement status
You can use the get
subcommand of the CLI to check whether SSL is currently being enforced:
_10supabase ssl-enforcement --project-ref {ref} get --experimental
Response if SSL is being enforced:
_10SSL is being enforced.
Response if SSL is not being enforced:
_10SSL is *NOT* being enforced.
Update enforcement
The update
subcommand is used to change the SSL enforcement status for your project:
_10supabase ssl-enforcement --project-ref {ref} update --enable-db-ssl-enforcement --experimental
Similarly, to disable SSL enforcement:
_10supabase ssl-enforcement --project-ref {ref} update --disable-db-ssl-enforcement --experimental
A note about Postgres SSL modes
Postgres supports multiple SSL modes on the client side. These modes provide different levels of protection. Depending on your needs, it is important to verify that the SSL mode in use is performing the required level of enforcement and verification of SSL connections.
The strongest mode offered by Postgres is verify-full
and this is the mode you most likely want to use when SSL enforcement is enabled. To use verify-full
you will need to download the Supabase CA certificate for your database. The certificate is available through the dashboard under the SSL Configuration section in the Database Settings page.
Once the CA certificate has been downloaded, add it to the certificate authority list used by Postgres.
_10cat {location of downloaded prod-ca-2021.crt} >> ~/.postgres/root.crt
With the CA certificate added to the trusted certificate authorities list, use psql
or your client library to connect to Supabase:
_10psql "postgresql://aws-0-eu-central-1.pooler.supabase.com:6543/postgres?sslmode=verify-full" -U postgres.<user>