]> git.proxmox.com Git - pve-http-server.git/commitdiff
fix #4859: properly configure TLSv1.3 only mode
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 19 Jul 2023 09:15:55 +0000 (11:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 20 Jul 2023 10:42:58 +0000 (12:42 +0200)
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>
src/PVE/APIServer/AnyEvent.pm

index e34c06abd1f3b5160958da5db89dd6539b2c0a01..cebd9ba60888e7dc72bce1b7de3b1fb7dda96cc2 100644 (file)
@@ -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}) {