Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1VyO-00Cqt8-5H for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Apr 2024 18:43:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s1VyL-001Nqv-N0 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Apr 2024 18:43:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1VyL-001Npp-DT for pgsql-hackers@lists.postgresql.org; Mon, 29 Apr 2024 18:43:30 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1VyF-000iVJ-D7 for pgsql-hackers@lists.postgresql.org; Mon, 29 Apr 2024 18:43:29 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4VSsfL3DwLz49PvR; Mon, 29 Apr 2024 21:43:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1714416202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zmai36aTCav61cD/kUtkS63/HU8W5KE6bRoElvUShaA=; b=DTynVgxuDfHpYshWLInGDAfnWe/4AaIFTB42rsMSJAAvsgxBB3eLJbYa0s8aHI4RkDxC+D /wehdHwVsRZlNFNwRBVFqomDPX1BAPuVzgpKhhxigP0ubVpK9MK6AlVxBFgqFXBxEPAO6K 76doeL65tybQs7deGIhaKvK7n6cVc0WgTnvErigkrZNDOt8jDEUe6rVnGATHlRxvjlwhV1 Kp41lLX5YGwFgwdJdXA412SIpexZwXfGGTETfvtZm2KOzlWgoCbOV1p3E5QR7rHq7e34yr i9biO7p7IVB28lGoFQCljLRAkafiPVBD9TTWB+H7btGb/czl/uy86FiS8hCxKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1714416202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zmai36aTCav61cD/kUtkS63/HU8W5KE6bRoElvUShaA=; b=sV1dT/L2aFgtpBgj27wIL9RaH8a2UYvp9EIrQHd0DKqMCZ8HAzXLP9fihJSacy+lqogoaf BWhZHvmo82XZwdjnhbcvdSCQO1mSimjA0I0Li//z0q1Z5c5H39a169V4dLWaHTARyKGULU VZ+8arQ1F7OiYF1DxlrL4UBwTJ3LfUrDPdSWsUVcS+u560gDpmDHDC9uWyDhxyjEQ8G4vF TBkT8ooW/CG3z/oqXaGXJROMPhhwKnK1jbjJ5RQptMu28V9q4NYDG3vqm3jPKCTYYdMyOm 9PG7i60whmx/t9WyVSnQPPQwZfKYg77P5DZss70/Clwj05XWDeLnHWyyroiOVw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1714416202; a=rsa-sha256; cv=none; b=tJ1VsMt6nAJaTI2LIhfAM4pTiGV/LGfh3nNdoxIiaLwrhn22J6A1ipBoFu6qFEELyGzc9g H7kdo5Y+L4FTK2lRJejhk/1IvJXrEi1Tb8J9Vs8dfP7dUG5jwoZww4q7qq3RP4GeGEDzor wNHX59UAm5XXxp3q4uo0lLeGaaZgv2fK3tf8FvWMg8IdxVAuM/cynKOimXmO518UF4fsVZ kplq2yL0h77XQM57aaBHfZYRoKcKt5HbnyViPNzK6XZ37D1dIRBdKC39hgzzS8aYpiVgrs Y5StOwDrwJ4KbSAABEqLkGn6FvmMvoHynd69XJjzSEfq8DMAeVCIcYISzTh4LQ== Message-ID: Date: Mon, 29 Apr 2024 21:43:22 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Direct SSL connection with ALPN and HBA rules To: Jacob Champion Cc: Michael Paquier , Postgres hackers References: <6aedcaa5-60f3-49af-a857-2c76ba55a1f3@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 29/04/2024 21:04, Jacob Champion wrote: > On Fri, Apr 26, 2024 at 3:51 PM Heikki Linnakangas wrote: >> I finally understood what you mean. So if the client supports ALPN, but >> the list of protocols that it provides does not include 'postgresql', >> the server should reject the connection with 'no_applicaton_protocol' >> alert. > > Right. (And additionally, we reject clients that don't advertise ALPN > over direct SSL, also during the TLS handshake.) > >> The attached patch makes that change. I used the alpn_cb() function in >> openssl's own s_server program as example for that. > > This patch as written will apply the new requirement to the old > negotiation style, though, won't it? My test suite sees a bunch of > failures with that. Yes, and that is what we want, right? If the client uses old negotiation style, and includes ALPN in its ClientHello, but requests protocol "noodles" instead of "postgresql", it seems good to reject the connection. Note that if the client does not request ALPN at all, the callback is not called, and the connection is accepted. Old clients still work because they do not request ALPN. >> Unfortunately the error message you got in the client with that was >> horrible (I modified the server to not accept the 'postgresql' protocol): >> >> psql "dbname=postgres sslmode=require host=localhost" >> psql: error: connection to server at "localhost" (::1), port 5432 >> failed: SSL error: SSL error code 167773280 > > > > I filed a bug upstream [1]. Thanks! -- Heikki Linnakangas Neon (https://neon.tech)