Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc95d215

Browse files
committed
Fix fallback behavior when server sends an ERROR early at startup
With sslmode=prefer, the desired behavior is to completely fail theconnection attempt, *not* fall back to a plaintext connection, if theserver responds to the SSLRequest with an error ('E') response insteadof rejecting SSL with an 'N' response. This was broken in commit05fd30c.Reported-by: Jacob ChampionReviewed-by: Michael PaquierDiscussion:https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.gmail.comBackpatch-through: 17
1 parent284c030 commitc95d215

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,6 +3521,12 @@ PQconnectPoll(PGconn *conn)
35213521
* byte here.
35223522
*/
35233523
conn->status=CONNECTION_AWAITING_RESPONSE;
3524+
3525+
/*
3526+
* Don't fall back to a plaintext connection after
3527+
* reading the error.
3528+
*/
3529+
conn->failed_enc_methods |=conn->allowed_enc_methods& (~conn->current_enc_method);
35243530
gotokeep_going;
35253531
}
35263532
else
@@ -3612,6 +3618,13 @@ PQconnectPoll(PGconn *conn)
36123618
* into AWAITING_RESPONSE state and let the code there
36133619
* deal with it. Note we have *not* consumed the "E"
36143620
* byte here.
3621+
*
3622+
* Note that unlike on an error response to
3623+
* SSLRequest, we allow falling back to SSL or
3624+
* plaintext connection here. GSS support was
3625+
* introduced in PostgreSQL version 12, so an error
3626+
* response might mean that we are connecting to a
3627+
* pre-v12 server.
36153628
*/
36163629
conn->status=CONNECTION_AWAITING_RESPONSE;
36173630
gotokeep_going;
@@ -3659,6 +3672,10 @@ PQconnectPoll(PGconn *conn)
36593672
}
36603673
elseif (pollres==PGRES_POLLING_FAILED)
36613674
{
3675+
/*
3676+
* GSS handshake failed. We will retry with an SSL or
3677+
* plaintext connection, if permitted by the options.
3678+
*/
36623679
CONNECTION_FAILED();
36633680
}
36643681
/* Else, return POLLING_READING or POLLING_WRITING status */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp