PostgreSQL and OpenSSL 4.0.0 — May 2026 Summary
Overview
OpenSSL 4.0.0 (GA April 2026) introduced return-value constification on APIs used by PostgreSQL's TLS layer (libpq, contrib/sslinfo), triggering compilation warnings. The thread resolved the technical approach, debated backpatch scope, reached consensus, and produced a rebased patchset ready for commit.
The Technical Problem
The core issue is not OpenSSL 4.0 in isolation but the interaction between OpenSSL 4.0's return-type constification and LibreSSL's lagging API. Specifically:
X509_get_subject_name()now returnsconst X509_NAME *in OpenSSL 4.0 (commit b0f2107b4404)- LibreSSL has not constified its equivalent APIs
- PostgreSQL maintains a single code path for both, so return values must be stored in non-const variables to satisfy LibreSSL's signatures
The patch must span OpenSSL 1.0.1 through 4.0.0 plus LibreSSL — roughly a decade of diverging API evolution.
Solution: Cast-Away-Constness at Call Boundaries
The patch applies unconstify() casts at OpenSSL call boundaries rather than propagating const through PostgreSQL's code or multiplying #ifdef branches. This is explicitly acknowledged as technical debt scoped to stable branches (14–19), not a long-term architectural choice.
A secondary fix addresses an OpenSSL 4.0 diagnostic string change ("ssl alert certificate revoked" → "tls alert certificate revoked") that broke SSL regression tests.
Backpatch Debate and Resolution
The central policy question — how far to backpatch — was debated and resolved:
- Gustafsson initially proposed skipping REL_14 (near EOL, asymmetric risk)
- Paquier countered that dropping forward-compatibility on a stable branch is unacceptable for users
- Tom Lane resolved: backpatch to all branches including 14, but commit shortly after the May minor releases (not before), giving three months of buildfarm soak before the next release window. Two remaining REL_14 minors (August, November) provide a safety valve.
Gustafsson conceded after realizing he had miscounted remaining 14.x releases. Consensus was reached unanimously.
Forward-Looking: v20 Will Address Root Cause
Gustafsson explicitly stated plans for PostgreSQL 20 to fix the underlying problem — likely by dropping LibreSSL support, splitting code paths, or raising the minimum OpenSSL version. The unconstify() approach is understood as a pragmatic bridge, not permanent architecture.
Current Status
Rebased patchset covering v14 through master posted and awaiting commit after the May 19–23 minor releases ship. Thread is in "waiting for commit" state.