Skip to content

Change default sslmode from "require" to "prefer"#1271

Merged
arp242 merged 1 commit intomasterfrom
sslmode-default
Apr 8, 2026
Merged

Change default sslmode from "require" to "prefer"#1271
arp242 merged 1 commit intomasterfrom
sslmode-default

Conversation

@arp242
Copy link
Copy Markdown
Collaborator

@arp242 arp242 commented Mar 9, 2026

Now that sslmode=prefer is supported, we can use that as the default.

"prefer" is the default used by libpq, pgx, and pretty much anything else connecting to PostgreSQL. I can't really find anything else that uses "require" as a default.

You could argue that "require" is a better default, but:

  1. "require" doesn't actually verify the certificates and accepts any certificate. I wouldn't say it's completely useless for production systems, but it does seem useless-adjacent. If you want SSL, you almost always want "verify-ca" or "verify-full".

  2. Copy/pasting a connection string used by pq to something else will mean you silently drop the ssl so it's a very brittle default.

  3. It's an annoying default because copy pasting a connection string from anything else to pq doesn't work.

pq has used "require" as a default for a long time, but because it's such a brittle default that's easy to lose by using $anything_else I think it's okay to change.

I will leave this open for a bit before merging, so if anyone objects it can be re-considered.

@arp242 arp242 force-pushed the sslmode-default branch 5 times, most recently from f760982 to 42ab0ff Compare March 18, 2026 14:15
Now that sslmode=prefer is supported, we can use that as the default.

"prefer" is the default used by libpq, pgx, and pretty much anything
else connecting to PostgreSQL. I can't really find anything else that
uses "require" as a default.

You could argue that "require" is a better default, but:

1. "require" doesn't actually verify the certificates and accepts any
   certificate. I wouldn't say it's completely useless for production
   systems, but it does seem useless-adjacent. If you want SSL, you
   almost always want "verify-ca" or "verify-full".

2. Copy/pasting a connection string used by pq to something else will
   mean you silently drop the ssl so it's a very brittle default.

3. It's an annoying default because copy pasting a connection string
   from anything else to pq doesn't work.

pq has used "require" as a default for a long time, but because it's
such a brittle default that's easy to lose by using $anything_else I
think it's okay to change.

I will leave this open for a bit before merging, so if anyone objects it
can be re-considered.
@arp242 arp242 force-pushed the sslmode-default branch from 42ab0ff to 6f7bc17 Compare April 8, 2026 15:01
@arp242 arp242 merged commit 004e5e8 into master Apr 8, 2026
14 checks passed
@arp242 arp242 deleted the sslmode-default branch April 8, 2026 15:05
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.

1 participant