pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Hugh Ranalli <hugh@whtc.ca>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Channel binding not supported using scram-sha-256 passwords
Date: Fri, 22 Feb 2019 14:28:09 +0900
Message-ID: <20190222052809.GE24416@paquier.xyz> (raw)
In-Reply-To: <134517f0-2736-37ed-02c0-da3d41c7a0db@2ndquadrant.com>
References: <CAAhbUMO89SqUk-5mMY+OapgWf-twF2NA5sCucbHEzMfGbvcepA@mail.gmail.com>
	<20190215211417.GC14824@momjian.us>
	<CAAhbUMPGQ6bNAJ22tQrA2RN245T+7Vb8g3VD3wvczDHqBTDevQ@mail.gmail.com>
	<20190218010614.GE1864@paquier.xyz>
	<56d28a96-6a18-8eb0-3c23-2a980a29a01f@2ndquadrant.com>
	<20190221044758.GK15532@paquier.xyz>
	<134517f0-2736-37ed-02c0-da3d41c7a0db@2ndquadrant.com>

On Thu, Feb 21, 2019 at 08:32:01PM +0100, Peter Eisentraut wrote:
> On 2019-02-21 05:47, Michael Paquier wrote:
>>  			if (conn->ssl_in_use)
>> +			{
>> +				/*
>> +				 * The server has offered SCRAM-SHA-256-PLUS, which is only
>> +				 * supported by the client if a hash of the peer certificate
>> +				 * can be created.
>> +				 */
>> +#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
>>  				selected_mechanism = SCRAM_SHA_256_PLUS_NAME;
>> +#endif
>> +			}
> 
> Is that right?  Won't we then just select nothing if the macro is not
> defined?

In the context of an SSL connection, the server would send both SCRAM
and SCRAM_PLUS as valid mechanisms if it supports channel binding
(HAVE_BE_TLS_GET_CERTIFICATE_HASH).  If the server does not support
channel binding, then only SCRAM is sent.

So you have the following possible cases for an SSL connection:
1) Server supports channel binding, sends SCRAM_PLUS and SCRAM as
allowed mechanisms.
1-1) Client supports channel binding, and it chooses SCRAM_PLUS.
1-2) Client does not support channel binding, and it chooses SCRAM.
2) Server does not support channel binding, sends SCRAM as allow
mechanism.
2-1) Client supports channel binding, still it has no choice but to
choose SCRAM.
2-2) Client does not support channel binding, it chooses SCRAM.

On HEAD, the bug you have spotted would cause case 1-2) to fail as the
client thinks that it should choose SCRAM_PLUS even if it does not
support it, causing a failure.  My patch changes things so as SCRAM
gets chosen instead of SCRAM_PLUS as the server sends both SCRAM and
SCRAM_PLUS to the client as possible choices, still the client is not
able to handle SCRAM_PLUS.

Does this explanation make sense?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (14+ messages)  latest in thread

Message-ID: <20190222052809.GE24416@paquier.xyz>
Permalink:  ../20190222052809.GE24416@paquier.xyz/
Also on:    postgresql.org/message-id/20190222052809.GE24416@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: michael@paquier.xyz, peter.eisentraut@2ndquadrant.com, hugh@whtc.ca, bruce@momjian.us
  Subject: Re: Channel binding not supported using scram-sha-256 passwords
  In-Reply-To: <20190222052809.GE24416@paquier.xyz>
  References: <CAAhbUMO89SqUk-5mMY+OapgWf-twF2NA5sCucbHEzMfGbvcepA@mail.gmail.com> <20190215211417.GC14824@momjian.us> <CAAhbUMPGQ6bNAJ22tQrA2RN245T+7Vb8g3VD3wvczDHqBTDevQ@mail.gmail.com> <20190218010614.GE1864@paquier.xyz> <56d28a96-6a18-8eb0-3c23-2a980a29a01f@2ndquadrant.com> <20190221044758.GK15532@paquier.xyz> <134517f0-2736-37ed-02c0-da3d41c7a0db@2ndquadrant.com> <20190222052809.GE24416@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox