Frontend/Backend Protocol: SSL / GSS Protocol Negotiation Problem

From: Jakob Egger <jakob(at)eggerapps(dot)at>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Frontend/Backend Protocol: SSL / GSS Protocol Negotiation Problem
Date: 2019-12-06 13:25:46
Message-ID: F27EEE9D-D04A-4B6B-B1F1-96EA4DD996D0@eggerapps.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 the following 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 know that.

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 compatibility with servers that do not support multiple attempts yet.

I've attached two proposed patches with these changes.

Best regards,
Jakob

Attachment Content-Type Size
0001-Allow-multiple-ssl-gss-negotiation-attempts.patch application/octet-stream 3.3 KB
0002-libpq-Retry-after-failed-ssl-gss-negotiation.patch application/octet-stream 5.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-12-06 13:30:28 Re: 64 bit transaction id
Previous Message Ranier Vilela 2019-12-06 12:59:15 RE: [Proposal] Level4 Warnings show many shadow vars