@@ -473,6 +473,7 @@ downloader() {
473
473
local _ciphersuites
474
474
local _err
475
475
local _status
476
+ local _retry
476
477
if check_cmd curl; then
477
478
_dld=curl
478
479
elif check_cmd wget; then
@@ -484,19 +485,21 @@ downloader() {
484
485
if [ " $1 " = --check ]; then
485
486
need_cmd " $_dld "
486
487
elif [ " $_dld " = curl ]; then
488
+ check_curl_for_retry_support
489
+ _retry=" $RETVAL "
487
490
get_ciphersuites_for_curl
488
491
_ciphersuites=" $RETVAL "
489
492
if [ -n " $_ciphersuites " ]; then
490
- _err=$( curl --proto ' =https' --tlsv1.2 --ciphers " $_ciphersuites " --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
493
+ _err=$( curl $_retry --proto ' =https' --tlsv1.2 --ciphers " $_ciphersuites " --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
491
494
_status=$?
492
495
else
493
496
echo " Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
494
497
if ! check_help_for " $3 " curl --proto --tlsv1.2; then
495
498
echo " Warning: Not enforcing TLS v1.2, this is potentially less secure"
496
- _err=$( curl --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
499
+ _err=$( curl $_retry --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
497
500
_status=$?
498
501
else
499
- _err=$( curl --proto ' =https' --tlsv1.2 --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
502
+ _err=$( curl $_retry --proto ' =https' --tlsv1.2 --silent --show-error --fail --location " $1 " --output " $2 " 2>&1 )
500
503
_status=$?
501
504
fi
502
505
fi
@@ -589,8 +592,20 @@ check_help_for() {
589
592
true # not strictly needed
590
593
}
591
594
595
+ # Check if curl supports the --retry flag, then pass it to the curl invocation.
596
+ check_curl_for_retry_support () {
597
+ local _retry_supported=" "
598
+ # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
599
+ if check_help_for " notspecified" " curl" " --retry" ; then
600
+ _retry_supported=" --retry 3"
601
+ fi
602
+
603
+ RETVAL=" $_retry_supported "
604
+
605
+ }
606
+
592
607
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
593
- # if support by local tools is detected. Detection currently supports these curl backends:
608
+ # if support by local tools is detected. Detection currently supports these curl backends:
594
609
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
595
610
get_ciphersuites_for_curl () {
596
611
if [ -n " ${RUSTUP_TLS_CIPHERSUITES-} " ]; then
@@ -635,7 +650,7 @@ get_ciphersuites_for_curl() {
635
650
}
636
651
637
652
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
638
- # if support by local tools is detected. Detection currently supports these wget backends:
653
+ # if support by local tools is detected. Detection currently supports these wget backends:
639
654
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
640
655
get_ciphersuites_for_wget () {
641
656
if [ -n " ${RUSTUP_TLS_CIPHERSUITES-} " ]; then
@@ -660,10 +675,10 @@ get_ciphersuites_for_wget() {
660
675
RETVAL=" $_cs "
661
676
}
662
677
663
- # Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2
664
- # excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad
678
+ # Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2
679
+ # excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad
665
680
# DH params often found on servers (see RFC 7919). Sequence matches or is
666
- # similar to Firefox 68 ESR with weak cipher suites disabled via about:config.
681
+ # similar to Firefox 68 ESR with weak cipher suites disabled via about:config.
667
682
# $1 must be openssl or gnutls.
668
683
get_strong_ciphersuites_for () {
669
684
if [ " $1 " = " openssl" ]; then
@@ -673,7 +688,7 @@ get_strong_ciphersuites_for() {
673
688
# GnuTLS isn't forgiving of unknown values, so this may require a GnuTLS version that supports TLS 1.3 even if wget doesn't.
674
689
# Begin with SECURE128 (and higher) then remove/add to build cipher suites. Produces same 9 cipher suites as OpenSSL but in slightly different order.
675
690
echo " SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-DTLS-ALL:-CIPHER-ALL:-MAC-ALL:-KX-ALL:+AEAD:+ECDHE-ECDSA:+ECDHE-RSA:+AES-128-GCM:+CHACHA20-POLY1305:+AES-256-GCM"
676
- fi
691
+ fi
677
692
}
678
693
679
694
main " $@ " || exit 1
0 commit comments