chore: ssl enforcement doesn't restart db (#53860)

## Problem

SSL enforcement currently warns that the database will be restarted.
This is no longer the case.

## Solution

SSL enforcement no longer restarts the database. Update references to
indicate that only non-SSL enabled connections are disabled. Only
display warning when enabling SSL enforcement.


## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
This commit is contained in:
Etienne Stalmans authored and GitHub committed 2026-11-24 17:51:11 +01:00
1 parent 1f6ee9e8b9
commit 76b8dfd2e5
5 files changed
+51 -25

No files matched your search

@@ -13,7 +13,7 @@ If clients fail with a `no pg_hba.conf entry ... ssl off` error after you enforc
<Admonition type="caution">
Applying or updating SSL enforcement triggers a fast database reboot. On small projects this usually completes in a few seconds, but larger databases may see a longer interruption.
Enforcing SSL immediately closes existing connections that don't use SSL. Clients must reconnect with SSL. Exising SSL enabled connections are unaffected.
</Admonition>
@@ -21,12 +21,6 @@ Applying or updating SSL enforcement triggers a fast database reboot. On small p
SSL enforcement can be configured via the "Enforce SSL on incoming connections" setting under the SSL Configuration section in [Database Settings page](/dashboard/project/_/database/settings) of the dashboard.
<Admonition type="note">
Updating SSL enforcement requires a brief database reboot. This restarts only the database and involves a few minutes of downtime.
</Admonition>
## Manage SSL enforcement via the Management API
You can also manage SSL enforcement using the Management API:
@@ -396,7 +396,6 @@ export const JitDbAccessConfiguration = () => {
</Button>
) : unavailableReason === 'ssl_enforcement_required' && ref ? (
<SSLEnforcementConfirmDialog
isTargetEnforced
isSubmitting={isEnablingSSLEnforcement}
onConfirm={handleEnableSSLEnforcement}
>
@@ -157,8 +157,8 @@ describe('SSLConfiguration', () => {
await userEvent.click(sslSwitch)
const dialog = await screen.findByRole('alertdialog')
expect(dialog).toHaveTextContent('Updating SSL enforcement involves a brief downtime')
expect(screen.getByRole('button', { name: 'Enable SSL' })).toBeInTheDocument()
expect(dialog).toHaveTextContent('Enforce SSL on connections?')
expect(screen.getByRole('button', { name: 'Enforce SSL' })).toBeInTheDocument()
// Controlled switch must not flip while the dialog is open
expect(sslSwitch).not.toBeChecked()
@@ -167,4 +167,30 @@ describe('SSLConfiguration', () => {
await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
expect(sslSwitch).not.toBeChecked()
})
it('disables SSL enforcement without a confirm dialog', async () => {
mockUseHighAvailability.mockReturnValue({ isHighAvailability: false, isPending: false })
mockSSLEnforcement({ appliedSuccessfully: true, currentConfig: { database: true } })
const updateRequests: unknown[] = []
addAPIMock({
method: 'put',
path: '/v1/projects/:ref/ssl-enforcement',
response: async ({ request }) => {
updateRequests.push(await request.json())
return HttpResponse.json<SslEnforcementResponse>({
appliedSuccessfully: true,
currentConfig: { database: false },
})
},
})
customRender(<SSLConfiguration />)
const sslSwitch = await screen.findByRole('switch')
expect(sslSwitch).toBeChecked()
await userEvent.click(sslSwitch)
await waitFor(() => expect(updateRequests).toEqual([{ requestedConfig: { database: false } }]))
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument()
})
})
@@ -48,15 +48,16 @@ export const SSLConfiguration = () => {
const isLoading = isHighAvailabilityPending || (!isHighAvailability && isSSLEnforcementPending)
const isSuccess = isHighAvailability || isSSLEnforcementSuccess
const { data: jitDbAccessConfiguration } = useJitDbAccessQuery({ projectRef: ref })
const { mutateAsync: updateSSLEnforcement, isPending: isSubmitting } =
useSSLEnforcementUpdateMutation({
const { mutate: updateSSLEnforcement, isPending: isSubmitting } = useSSLEnforcementUpdateMutation(
{
onSuccess: () => {
toast.success('Successfully updated SSL configuration')
},
onError: (error) => {
toast.error(`Failed to update SSL enforcement: ${error.message}`)
},
})
}
)
const { can: canUpdateSSLEnforcement } = useAsyncCheckPermissionsV2(
FGA_PERMISSIONS.PROJECT.DATABASE_SSL_CONFIG_WRITE
@@ -121,9 +122,18 @@ export const SSLConfiguration = () => {
[sslCertificateUrlTemplate, env]
)
const toggleSSLEnforcement = async () => {
const setSSLEnforcement = (isTargetEnforced: boolean) => {
if (!ref) return console.error('Project ref is required')
await updateSSLEnforcement({ projectRef: ref, requestedConfig: { database: !isEnforced } })
updateSSLEnforcement({ projectRef: ref, requestedConfig: { database: isTargetEnforced } })
}
// Only enabling enforcement closes existing connections, so only enabling needs a confirmation
const handleSwitchChange = (isChecked: boolean) => {
if (isChecked) {
setIsConfirmDialogOpen(true)
} else {
setSSLEnforcement(false)
}
}
return (
@@ -164,7 +174,7 @@ export const SSLConfiguration = () => {
size="large"
checked={isEnforced}
disabled={isSwitchDisabled}
onCheckedChange={() => setIsConfirmDialogOpen(true)}
onCheckedChange={handleSwitchChange}
/>
</div>
</TooltipTrigger>
@@ -183,9 +193,8 @@ export const SSLConfiguration = () => {
<SSLEnforcementConfirmDialog
open={isConfirmDialogOpen}
onOpenChange={setIsConfirmDialogOpen}
isTargetEnforced={!isEnforced}
isSubmitting={isSubmitting}
onConfirm={toggleSSLEnforcement}
onConfirm={() => setSSLEnforcement(true)}
/>
</FormLayout>
{isSSLEnforcementSuccess && !sslEnforcementConfiguration.appliedSuccessfully && (
@@ -12,9 +12,8 @@ import {
} from 'ui'
interface SSLEnforcementConfirmDialogProps {
isTargetEnforced: boolean
isSubmitting: boolean
onConfirm: () => Promise<void>
onConfirm: () => void
/**
* Controlled mode for callers whose control can't act as the dialog trigger
* (e.g. a switch, where a disabled control must never open the dialog).
@@ -25,7 +24,6 @@ interface SSLEnforcementConfirmDialogProps {
}
export const SSLEnforcementConfirmDialog = ({
isTargetEnforced,
isSubmitting,
onConfirm,
open,
@@ -37,16 +35,16 @@ export const SSLEnforcementConfirmDialog = ({
{children !== undefined && <AlertDialogTrigger asChild>{children}</AlertDialogTrigger>}
<AlertDialogContent size="medium">
<AlertDialogHeader>
<AlertDialogTitle>Updating SSL enforcement involves a brief downtime</AlertDialogTitle>
<AlertDialogTitle>Enforce SSL on connections?</AlertDialogTitle>
<AlertDialogDescription>
A database restart is required for SSL enforcement changes to take place, and this
involves a few minutes of downtime. Confirm to proceed now?
Enforcing SSL immediately closes existing connections that don't use SSL. Clients must
reconnect with SSL. Existing SSL enabled connections are unaffected.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={isSubmitting}>Cancel</AlertDialogCancel>
<AlertDialogAction variant="warning" disabled={isSubmitting} onClick={onConfirm}>
{isTargetEnforced ? 'Enable SSL' : 'Disable SSL'}
Enforce SSL
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>