Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwgHS-0000Xs-G8 for pgsql-general@arkaria.postgresql.org; Thu, 21 Feb 2019 04:48:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gwgHQ-0004TX-O0 for pgsql-general@arkaria.postgresql.org; Thu, 21 Feb 2019 04:48:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwgHO-00047t-Jb for pgsql-general@lists.postgresql.org; Thu, 21 Feb 2019 04:48:16 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwgHG-000215-Lg for pgsql-general@lists.postgresql.org; Thu, 21 Feb 2019 04:48:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 63E5722062; Wed, 20 Feb 2019 23:48:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 20 Feb 2019 23:48:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=iGT6gO120jfTlLDiE6GD+1PrPWv Byst4wL/1zYW4eP8=; b=AZR51QyQc2LqEDQTf3ye72wiZPqqtlKZhzG55hgrF8z /sXp/sU7Wg51ShVWHaatG4eDoHwcHYK2QQelPLV0uBSVTPLePcoRUZ7ZLiiSXHap M5YB5blQArEqHDFQJ2WrEdPMlkjf8u+sO9rHyXDpdMGF5oMVn0kePu85ZODErc9E 3DbpUoS3Js9gaVz4130LxEkpRUREQ9j0PnqNR5kvOZE0bKT7uYGRYCM0JsQh7ckh 3/ODJUcNl1hL84oy4InKbmSX+fuGpWDGvLB6y//TLfuoAq9OAB3eUQXM0oCMPyg5 v7mhqngWi9w7rZ+fk7tWd+ihh/C6uQWj4TXU1OD7nCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=iGT6gO 120jfTlLDiE6GD+1PrPWvByst4wL/1zYW4eP8=; b=4B/mFZb2G30Ko74lTq6XVC e5QkRMYm7G+/uPebt0yxGk64BFy2jjzSKXvAUUVoS81VmAbek500NwrGoPP0lFxq QUjGszB26wQZVDWMBToimRd85j+L7tlhxuMyqamH+O+sIBjsgdcPY5wHEmiewEFC ujgjFFYFLuG/bSROSbegakrXynh0pu5fHca2gNsYuN0x/CJGR5+Pgds4Xtv9hDzj qLfg/njh4QE0THqLlgFRq4+6Rfj03Oe7RKfy95Xtpa9ZdnhKIP8zXaVdVEXB9Pty zFmiW4dU/L/WQNy2R+p2LvlVrG3Mk0AJu883jtEEsdl32KXSzeaFJx6w+mGigRMw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrtdejgdejgeculddtuddrgedtledrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucfkphepiedurddvudehrddufeejrdduiedvnecurfgrrhgr mhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id DD1BDE419A; Wed, 20 Feb 2019 23:48:01 -0500 (EST) Date: Thu, 21 Feb 2019 13:47:58 +0900 From: Michael Paquier To: Peter Eisentraut Cc: Hugh Ranalli , Bruce Momjian , pgsql-general@lists.postgresql.org Subject: Re: Channel binding not supported using scram-sha-256 passwords Message-ID: <20190221044758.GK15532@paquier.xyz> References: <20190215211417.GC14824@momjian.us> <20190218010614.GE1864@paquier.xyz> <56d28a96-6a18-8eb0-3c23-2a980a29a01f@2ndquadrant.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="m8RPluiNA7RIyL8J" Content-Disposition: inline In-Reply-To: <56d28a96-6a18-8eb0-3c23-2a980a29a01f@2ndquadrant.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --m8RPluiNA7RIyL8J Content-Type: multipart/mixed; boundary="TlDjLAx2PuPdVSSH" Content-Disposition: inline --TlDjLAx2PuPdVSSH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 20, 2019 at 04:53:32PM +0100, Peter Eisentraut wrote: > I think there is a bug in the frontend code. If the server offers > SCRAM-SHA-256-PLUS, the client will choose it if SSL is in use, but it > will later fail with this error message if not > HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH. Good catch! Indeed that's not a good idea. What do you think about the attached to fix the issue? -- Michael --TlDjLAx2PuPdVSSH Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="scram-libpq-fix-v1.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 08a5a9c1f3..4bb529ba3b 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -526,14 +526,24 @@ pg_SASL_init(PGconn *conn, int payloadlen) =20 /* * Select the mechanism to use. Pick SCRAM-SHA-256-PLUS over anything - * else if a channel binding type is set. Pick SCRAM-SHA-256 if - * nothing else has already been picked. If we add more mechanisms, a - * more refined priority mechanism might become necessary. + * else if a channel binding type is set and if the client supports it. + * Pick SCRAM-SHA-256 if nothing else has already been picked. If we + * add more mechanisms, a more refined priority mechanism might become + * necessary. */ if (strcmp(mechanism_buf.data, SCRAM_SHA_256_PLUS_NAME) =3D=3D 0) { 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 =3D SCRAM_SHA_256_PLUS_NAME; +#endif + } else { /* --TlDjLAx2PuPdVSSH-- --m8RPluiNA7RIyL8J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlxuLX4ACgkQnvQgOdby QH1n6w//T6BD+56BQXuZAUlTv4R/k7pci/G+cpqjpSVjl+WEzzdOj8bJ4KaM0H27 BZF9Rs7hJwr8G9XihqNyabQARV+2J8mVniAi6TWJ12DZSZAnpPoIGeHcvA8R0f+G iSEsEVspdkLspMOhucpBC1QrcotG7Xsp/NBQr+OCzpFhMdS6cXJu5bZGdpdoJ5rQ 6qp1BwtwOtWG0lroqVfhMPT/LCqelXkBOt6Np32U490iMbaV4CuuBsJ+XqKsbwaV Mz4FsXs/vOcHPPes1P04nVhLQ9IS/ebij3r4mpcz9t6HL7856OKJ0TygEmUY7yNM GFHCOrSVzFu4E/Vf6VTOWAnW7L7GcNkMTXTBZoy4kKL2DPEigrwMLyieOfRvAxtB Afjj+w+YA7V/fQ+ZunqtlPTHE6G5uJGsb8DlTs/915z1WXzQC2GYw84BFPHGbCkM ySZCdWdnbmXgPu5HCr52KITwcQnRBu3oEGAqotYuuNNPr81qWnbuYh2lViwsqJVO 5p9R/jPKYiPwUEP/lFIZghkNSlwIKeQoj/87LFkUBW0craJFLKF0/KplTj+psLac 6C2kZXpFO1t03AW8tbzFVDECoJVQAmqKbeJAVdZv2fxvlhB3sr0np19pW+H43RSY tG2/uBYQz126BOW9FUljlCRjYHaNzPyxgl9iXY1LtrVDpM86BG0= =0MC+ -----END PGP SIGNATURE----- --m8RPluiNA7RIyL8J--