Skip to content

Surface PostgreSQL ErrorResponse during SSL negotiation - #1346

Draft
aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/tls-upgrade-error-response-1317
Draft

aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/tls-upgrade-error-response-1317

Conversation

@aryansk

@aryansk aryansk commented Aug 16, 2026

Copy link
Copy Markdown

Fixes #1317.

When a server replies to SSLRequest with a pre-auth E... error payload, preserve the server's diagnostic text in an asyncpg InterfaceError instead of replacing it with the generic rejected SSL upgrade message.

Includes a regression test for the simplified pre-auth error form described in the issue.

elprans added a commit that referenced this pull request Sep 20, 2026
An `ErrorResponse` to `SSLRequest` is currently reported as an SSL
refusal, while transport fallback only handles a narrow set of
authorization errors.

Follow libpq transport-selection behavior and improve the SSL exchange
diagnostic without trusting pre-TLS server text or exposing SQLSTATE
(see CVE-2024-10977).  Make it so that alternative transports in
allow/prefer retries are only tried _before_ authentication succeeds,
not after.  While here, align asyncpg with libpq and require `ssl` to be
set to a mandatory TLS mode (or explicit context) when `direct_tls` is
specified.

Fixes #1317.
Closes #1346.
Closes #1348.
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.

TLSUpgradeProto.data_received hides PostgreSQL ErrorResponse behind generic 'rejected SSL upgrade' ConnectionError

1 participant