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 1gx3Ns-0006w0-2q for pgsql-general@arkaria.postgresql.org; Fri, 22 Feb 2019 05:28:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gx3Nq-0004QM-Fn for pgsql-general@arkaria.postgresql.org; Fri, 22 Feb 2019 05:28:26 +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 1gx3No-0004QE-I9 for pgsql-general@lists.postgresql.org; Fri, 22 Feb 2019 05:28:26 +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 1gx3Ng-0001PV-EB for pgsql-general@lists.postgresql.org; Fri, 22 Feb 2019 05:28:23 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5EE6222C06; Fri, 22 Feb 2019 00:28:15 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 22 Feb 2019 00:28:15 -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=sWOrTV/AZ+rAn4ZyAHglxatTG8A 6fURo0wxj9v0hKdA=; b=ZkI8MQFh6jQ+f9Zu8cffCfQepC7XdQHRiyFdVTf/w51 RqPHhkJ+7tTHsE8SzPHiKNfR3XWP7EUapa3wDgimF+SAJ7UBVJduI8uowk835v7z iSqyl0TyRXv2cYUqGV4BuleBRC1/4TZv3tYz01hXBhp/v3pgqASfIr4jVzsSWGsR yA9aH295cDTQKQcOc+A2+WuS8MuM1+jgJ4Kb5fts6BqsbqFwkqBBe0Sh2y5ST/i6 4uSVA3/icFjQG/Ms+vR6ZTOst/1ehxwrGxb2LuvzomNVjVyJD+KyxMmt4LL4/Uyn c5/8OPQy5XiBz50nNbnEmjdrczQo9qJVMXAF7WX7VQA== 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=sWOrTV /AZ+rAn4ZyAHglxatTG8A6fURo0wxj9v0hKdA=; b=4oMBoYBaSJJz6slbHYQt0i 0wqeh2pe/EXfrkMLNPiMq4aXfCUHsYd4gWRV5/rDG/QENTcn+vQrfxbiGvIqaAWa BnIEG7LHpvsUBPkvjDADkRNyxoXzBcQJYxyYDfUPlc+lvfXX95iJGbHrNz88DBFz +QurjuQhzsIVGquaACwIv+NogqcVz6NFUoskVRy/ySFLFBOQrP1pS+ytQwcR5pUt odp+g2knOcl12qc6Rk0Qx3MU+fE1WwrNFXofp5LVcrG+CSUM0U/kff0G6zxxKk50 1Q9dOwnWB9nZGHz9A8H4Xhlq7SwEhMkkvfjtcAyEo3AwrUDZKLd9WmTJSElMDbhQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrtdelgdekvdculddtuddrgedtledrtddtmd 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 CD50DE425A; Fri, 22 Feb 2019 00:28:12 -0500 (EST) Date: Fri, 22 Feb 2019 14:28:09 +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: <20190222052809.GE24416@paquier.xyz> References: <20190215211417.GC14824@momjian.us> <20190218010614.GE1864@paquier.xyz> <56d28a96-6a18-8eb0-3c23-2a980a29a01f@2ndquadrant.com> <20190221044758.GK15532@paquier.xyz> <134517f0-2736-37ed-02c0-da3d41c7a0db@2ndquadrant.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="N1GIdlSm9i+YlY4t" Content-Disposition: inline In-Reply-To: <134517f0-2736-37ed-02c0-da3d41c7a0db@2ndquadrant.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --N1GIdlSm9i+YlY4t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D SCRAM_SHA_256_PLUS_NAME; >> +#endif >> + } >=20 > 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 --N1GIdlSm9i+YlY4t Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlxviGkACgkQnvQgOdby QH1ZJQ/8DCKxA9cCvtyQu5Pwl0IVRhC69kFaPo26NBTs00hegKegoSyrz8v9D2mu rl45aRVWvvqPtbFeWeJ5wdCukm602xdlPUYqpJC+Yeq+5vZdfLHZSjmHrmj3vToV 9WG2UrPeYytkKo1PT3DmekQDd/Z/gjw0fxq1k0oBLL4XTu9jfVvGYs2isFHOTmZh XDCkFPftAFjw5fSjJO7XnrjOcGN6MgSOs2HZDbUn4XULC4U3itBJhUfeLaaTBFxi 0Du5FdIdwhSspktU0YzuT9pJabCeZI0ojmc9UWryMQhzm2bZXKKICtguxq7guMgq FYtSRHTZBnw/yJQw6J9dWTYuu54TdBsF5Yw7FVQb3O2PlBcVIwzw2UJYIhRqDB+A rrA/IN9MJcAjUyop7oej1ND40rXdalUF3OjPT5OLOsHR/DvdpzqZCm4jR9x/lrEA V+W1YefS/rkA0IP2hGWNToYzwd3RrKiIU+BR7M35WCD0qN808SzFkB3HCvs5kBka icMV6R7wmDcV7CXyM29LCXNekWj40XpGRKNryricy80SXOUqW7gKU9mCM4HStHDG 04gL2eJja27bYt6A2SmJMO39WNmicnxlexUQOngGiHOiKfwM1ug29WVWxc2gZUv7 hmRiZsOlzRY2pNsT2Qyf+hEaJDit8VLD0ndipaxIsuGdgr2a5f8= =8X1Q -----END PGP SIGNATURE----- --N1GIdlSm9i+YlY4t--