public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH http-server v2] fix #4859: properly configure TLSv1.3 only mode
Date: Wed, 19 Jul 2023 11:15:55 +0200	[thread overview]
Message-ID: <20230719091555.3516251-1-f.gruenbichler@proxmox.com> (raw)

set_min/max_proto_version is recommended upstream nowadays, and it seems to be
required for some reason if *only* TLS v1.3 is supposed to be enabled.

querying via get_options gives us the union of
- system-wide openssl defaults
- our internal SSL defaults
- flags configured by the user via /etc/default/pveproxy

note that by default only 1.2 and 1.3 are enabled in the first place, so
disabling either leaves a single version being set as min and max.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
use `&Net::..` instead of `Net::..` for the constants, else spiceproxy chokes
on the usage. either variant seems to work for pveproxy.. ?

 src/PVE/APIServer/AnyEvent.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index 1fd7a74..7a07193 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -2012,6 +2012,23 @@ sub new {
 	    warn "Failed to set TLS 1.3 ciphersuites '$ciphersuites'\n"
 		if !Net::SSLeay::CTX_set_ciphersuites($self->{tls_ctx}->{ctx}, $ciphersuites);
 	}
+
+	my $opts = Net::SSLeay::CTX_get_options($self->{tls_ctx}->{ctx});
+	my $min_version = Net::SSLeay::TLS1_1_VERSION();
+	my $max_version = Net::SSLeay::TLS1_3_VERSION();
+	if ($opts & &Net::SSLeay::OP_NO_TLSv1_1) {
+	    $min_version = Net::SSLeay::TLS1_2_VERSION();
+	}
+	if ($opts & &Net::SSLeay::OP_NO_TLSv1_2) {
+	    $min_version = Net::SSLeay::TLS1_3_VERSION();
+	}
+	if ($opts & &Net::SSLeay::OP_NO_TLSv1_3) {
+	    die "misconfigured TLS settings - cannot disable all supported TLS versions!\n"
+		if $min_version && $min_version == Net::SSLeay::TLS1_3_VERSION();
+	    $max_version = Net::SSLeay::TLS1_2_VERSION();
+	}
+	Net::SSLeay::CTX_set_min_proto_version($self->{tls_ctx}->{ctx}, $min_version) if $min_version;
+	Net::SSLeay::CTX_set_max_proto_version($self->{tls_ctx}->{ctx}, $max_version);
     }
 
     if ($self->{spiceproxy}) {
-- 
2.39.2





             reply	other threads:[~2023-07-19  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19  9:15 Fabian Grünbichler [this message]
2023-07-20 15:20 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230719091555.3516251-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal