Frontend/Backend Protocol: SSL / GSS Protocol Negotiation Problem - Mailing list pgsql-hackers

From Jakob Egger
Subject Frontend/Backend Protocol: SSL / GSS Protocol Negotiation Problem
Date
Msg-id F27EEE9D-D04A-4B6B-B1F1-96EA4DD996D0@eggerapps.at
Whole thread Raw
Responses Re: Frontend/Backend Protocol: SSL / GSS Protocol Negotiation Problem  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Hi!

I've received a bug report from a PostgreSQL user that psql 12.1 failed to connect to a PostgreSQL 12.1 server, with
thefollowing error message: 

psql: error: could not connect to server: FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0

After inspecting a TCP dump, I realised that libpq apparently sent a GSS startup packet, got 'N' (not supported)
response,then tried a SSL startup packet, at which point the server sent an error. 

The bug report is available at the following URL:
https://github.com/PostgresApp/PostgresApp/issues/537

After inspecting postmaster.c, it seems that postmaster only allows a single negotiation attempt, but libpq doesn't
knowthat. 

I'm not familiar with GSS, but from my naive point of view it would seem that we should fix this issue as follows:

1) On the server side, allow multiple negotiation attempts (eg. allow SSL negotiation after a rejected GSS negotiation
attempt)

2) On the client side, detect an error message after the second negotiation attempt, and reconnect, to ensure
compatibilitywith servers that do not support multiple attempts yet. 

I've attached two proposed patches with these changes.

Best regards,
Jakob



Attachment

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: RE: [Proposal] Level4 Warnings show many shadow vars
Next
From: Robert Haas
Date:
Subject: Re: 64 bit transaction id