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 1s6eAo-000uuW-Ju for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2024 22:29:36 +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 1s6eAo-00657s-Lq for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2024 22:29:34 +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 1s6eAo-00657j-Bk for pgsql-hackers@lists.postgresql.org; Mon, 13 May 2024 22:29:34 +0000 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s6eAk-0005Vr-PA for pgsql-hackers@lists.postgresql.org; Mon, 13 May 2024 22:29:33 +0000 Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-6a04bb4f6d5so25542276d6.0 for ; Mon, 13 May 2024 15:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1715639369; x=1716244169; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eLNetH6bjOUQFWFbW4C1LDJ2CRSl9bZkzebiaUgTxGw=; b=a0X+m9vHNO1kFdN2jQVUR04b2c/IKtjSvmsyTIF5ZCUroQF+3RckX1VWaSbYc/lTsG pia3XjM1UL89XyYqjg9yTg4g/c4evincdBhagoXP96o/nP9+NWLrB/IprVP6HlD3vnHX GS4WVWEUtF/c8ldYHvdZ+9jOPbXYCK/OL3zHWZwBHjgxW9qSlsZxthd3+UWpUVoEbWZB IX6UwnuqbIAfT6IWTl1fxTCiB2Bx06JOjDCinguDgSY1DM3IEqSEzSqdf+jLKbSmqNa+ xMXv8ayKLKnTiEmg4kzm1nwIuLV3O6ADQ+0u4HBXy35GpIRytf506PRvJrAWDTaOGijS TXoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715639369; x=1716244169; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eLNetH6bjOUQFWFbW4C1LDJ2CRSl9bZkzebiaUgTxGw=; b=eMUCeCKlni9xbN8M+ze1C349n3p4uo/mz/2p4B0xX9BZMePrdGSGS2nFlY1LrV8F5c 69G9NV9mPER7bxvSpKn20ZEraTZgOiOBVeuKIdViMKLRDMsH/Q2eTAIaSzpCn2KOI7C1 8/gc9jgLBtIbnVzVXbp+oTqftoDQXnQpf15H6r1GQlm3aBjS8246FUfugbK7jX2gvFg7 0ZxJ/IJHxZV+XKspe50+oM6qjZrWEskqEF+Tq1qFM07XAxo1uHYbBS+rXKcV1ZKQXsPO Hr3U7dXK/5iscox5M5tvHTl/kLR9OYyse08WW8Iepw81Y/tt9uM90YHPos8MWv7oyXj6 AzAg== X-Forwarded-Encrypted: i=1; AJvYcCUbvxP2F29oTvXnpEq0kvMa9GB1QMLxevPm997Omk5HXSZy2iIA3FIaUjZCeFjHBEMBMBaUG8HmFtfviMb16i9i53WNL/O9cKk9QuL1pBpDBpUF X-Gm-Message-State: AOJu0YzbiGv76D/oq+GVLEryYILsf71g6ByeEJ15MXE4fSDxlr6aSM4k DHK3yafrMb202osMvITbJxivx60dwhov5xzPhKzFTRLkpist6s82WnXQvYQt2j5Q1z+o1yGZg2n IReK+nIVwb2NjtHzoqmYILTexCK2iKum2Di8W X-Google-Smtp-Source: AGHT+IGnAG+Rhx4MEMOcEVsdSqZyYUlhRnjKtITLDDAY74JIMG6QUjgz2dOEO7y/dtC8bqEAoD3DMg6J0mGkmx0UuyY= X-Received: by 2002:a05:6214:5c42:b0:6a0:cafc:aaa with SMTP id 6a1803df08f44-6a168166e40mr110255446d6.20.1715639368967; Mon, 13 May 2024 15:29:28 -0700 (PDT) MIME-Version: 1.0 References: <5a79ed71-b365-4b20-80bc-9c2bf97bf84b@iki.fi> <3a6f126c-e1aa-4dcc-9252-9868308f6cf0@iki.fi> <1a717f65-7390-4111-8efd-c6e9b213805e@iki.fi> <3fdaf4b1-82d1-45bb-8175-f97ff53a1f01@iki.fi> In-Reply-To: From: Jacob Champion Date: Mon, 13 May 2024 15:29:17 -0700 Message-ID: Subject: Re: Direct SSL connection with ALPN and HBA rules To: Robert Haas Cc: Heikki Linnakangas , Daniel Gustafsson , Michael Paquier , Postgres hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, May 13, 2024 at 9:13=E2=80=AFAM Robert Haas = wrote: > I find this idea to be a massive improvement over the status quo, +1 > and > I didn't spot any major problems when I read through the patch, > either. Definitely not a major problem, but I think select_next_encryption_method() has gone stale, since it originally provided generality and lines of fallback that no longer exist. In other words, I think the following code is now misleading: > if (conn->sslmode[0] =3D=3D 'a') > SELECT_NEXT_METHOD(ENC_PLAINTEXT); > > SELECT_NEXT_METHOD(ENC_NEGOTIATED_SSL); > SELECT_NEXT_METHOD(ENC_DIRECT_SSL); > > if (conn->sslmode[0] !=3D 'a') > SELECT_NEXT_METHOD(ENC_PLAINTEXT); To me, that implies that negotiated mode takes precedence over direct, but the point of the patch is that it's not possible to have both. And if direct SSL is in use, then sslmode can't be "allow" anyway, and we definitely don't want ENC_PLAINTEXT. So if someone proposes a change to select_next_encryption_method(), you'll have to remember to stare at init_allowed_encryption_methods() as well, and think really hard about what's going on. And vice-versa. That worries me. > I don't have a strong opinion about whether sslnegotiation=3Ddirect > should error out (as you propose here) or silently promote sslmode to > require. I think either is defensible. I'm comforted that, since sslrootcert=3Dsystem already does it, plenty of use cases will get that for free. And if you decide in the future that you really really want it to promote, it won't be a compatibility break to make that change. (That gives us more time for wider v16-17 adoption, to see how the sslrootcert=3Dsystem magic promotion behavior is going in practice.) > Had I been implementing it, I > think I would have done as Jacob proposes, just because once we've > forced a direct SSL negotiation surely the only sensible behavior is > to be using SSL, unless you think there should be a > silently-reconnect-without-SSL behavior, which I sure don't. We still allow GSS to preempt SSL, though, so "forced" is probably overstating things. > It's really hard to believe in 2024 that anyone should ever be using a > setting that may or may not encrypt the connection. There's http and > https but there's no httpmaybes. +1. I think (someone hop in and correct me please) that Opportunistic Encryption for HTTP mostly fizzled, and they gave it a *lot* of thought. --Jacob