@@ -473,6 +473,7 @@ downloader() {
473473 local _ciphersuites
474474 local _err
475475 local _status
476+ local _retry
476477 if check_cmd curl; then
477478 _dld=curl
478479 elif check_cmd wget; then
@@ -484,19 +485,21 @@ downloader() {
484485 if [ " $1 " = --check ]; then
485486 need_cmd " $_dld "
486487 elif [ " $_dld " = curl ]; then
488+ check_curl_for_retry_support
489+ _retry=" $RETVAL "
487490 get_ciphersuites_for_curl
488491 _ciphersuites=" $RETVAL "
489492 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 )
491494 _status=$?
492495 else
493496 echo " Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
494497 if ! check_help_for " $3 " curl --proto --tlsv1.2; then
495498 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 )
497500 _status=$?
498501 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 )
500503 _status=$?
501504 fi
502505 fi
@@ -589,8 +592,20 @@ check_help_for() {
589592 true # not strictly needed
590593}
591594
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+
592607# 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:
594609# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
595610get_ciphersuites_for_curl () {
596611 if [ -n " ${RUSTUP_TLS_CIPHERSUITES-} " ]; then
@@ -635,7 +650,7 @@ get_ciphersuites_for_curl() {
635650}
636651
637652# 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:
639654# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
640655get_ciphersuites_for_wget () {
641656 if [ -n " ${RUSTUP_TLS_CIPHERSUITES-} " ]; then
@@ -660,10 +675,10 @@ get_ciphersuites_for_wget() {
660675 RETVAL=" $_cs "
661676}
662677
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
665680# 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.
667682# $1 must be openssl or gnutls.
668683get_strong_ciphersuites_for () {
669684 if [ " $1 " = " openssl" ]; then
@@ -673,7 +688,7 @@ get_strong_ciphersuites_for() {
673688 # GnuTLS isn't forgiving of unknown values, so this may require a GnuTLS version that supports TLS 1.3 even if wget doesn't.
674689 # Begin with SECURE128 (and higher) then remove/add to build cipher suites. Produces same 9 cipher suites as OpenSSL but in slightly different order.
675690 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
677692}
678693
679694main " $@ " || exit 1
0 commit comments