From e3000f670508631ef1e1af872136824dad556e08 Mon Sep 17 00:00:00 2001 From: mojila Date: Fri, 19 Dec 2025 10:34:37 +0700 Subject: [PATCH] fix: add TLS 1.2 fallback when TLS 1.3 is not supported Handle cases where curl doesn't support TLS 1.3 by falling back to TLS 1.2 --- Mido.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Mido.sh b/Mido.sh index 9b517d0..ed373fc 100755 --- a/Mido.sh +++ b/Mido.sh @@ -241,8 +241,23 @@ scurl_file() { # --location: Microsoft likes to change which endpoint these downloads are stored on but is usually kind enough to add redirects # --fail: Return an error on server errors where the HTTP response code is 400 or greater - curl --progress-bar --location --output "$part_file" --continue-at - --max-filesize 10G --fail --proto =https "--tlsv$tls_version" --http1.1 -- "$url" || { - error_code=$? + curl --progress-bar --location --output "$part_file" --continue-at - --max-filesize 10G --fail --proto =https "--tlsv$tls_version" --http1.1 -- "$url" + error_code=$? + + if [ "$error_code" -ne 0 ]; then + # Fallback to TLS 1.2 if TLS 1.3 is not supported (error code 4) + if [ "$error_code" -eq 4 ] && [ "$tls_version" = "1.3" ]; then + echo_info "TLS 1.3 not supported by curl, falling back to TLS 1.2..." + curl --progress-bar --location --output "$part_file" --continue-at - --max-filesize 10G --fail --proto =https --tlsv1.2 --http1.1 -- "$url" + error_code=$? + + if [ "$error_code" -eq 0 ]; then + # Success after fallback + mv "$part_file" "${out_file}${unverified_ext}" + return 0 + fi + fi + handle_curl_error "$error_code" error_action=$? @@ -256,7 +271,7 @@ scurl_file() { fi return "$error_action" - } + fi # Full downloaded succeeded, ready for verification check mv "$part_file" "${out_file}${unverified_ext}"