Skip to content

Commit

Permalink
Simplifying certs handling
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon authored Mar 2, 2024
1 parent 1b19f39 commit 103efb4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set -euo pipefail

SCRIPT_PATH="/tmp/downloader.sh"
LATEST_SCRIPT_PATH="/media/fat/Scripts/.config/downloader/downloader_latest.sh"
CACERT_NEEDED="/media/fat/Scripts/.config/downloader/cacert_needed"
CACERT_PEM="/etc/ssl/certs/cacert.pem"

if (( $(date +%Y) < 2000 )) ; then
Expand All @@ -39,6 +38,10 @@ if (( $(date +%Y) < 2000 )) ; then
fi
fi

if [ -s "${CACERT_PEM}" ] ; then
export CURL_CA_BUNDLE="${CACERT_PEM}"
fi

download_file() {
local DOWNLOAD_PATH="${1}"
local DOWNLOAD_URL="${2}"
Expand All @@ -62,12 +65,6 @@ download_file() {
return
;;
60|77|35|51|58|59|82|83)
if [ -s /etc/ssl/certs/cacert.pem ] ; then
export CURL_SSL="--cacert ${CACERT_PEM}"
touch "${CACERT_NEEDED}"
continue
fi

set +e
dialog --keep-window --title "Bad Certificates" --defaultno \
--yesno "CA certificates need to be fixed, do you want me to fix them?\n\nNOTE: This operation will delete files at /etc/ssl/certs" \
Expand Down Expand Up @@ -142,9 +139,6 @@ rm ${SCRIPT_PATH} 2> /dev/null || true
if [ -s "${LATEST_SCRIPT_PATH}" ] ; then
cp "${LATEST_SCRIPT_PATH}" "${SCRIPT_PATH}"
if [[ "${CURL_SSL:-}" != "--insecure" ]] ; then
if [ -f "${CACERT_NEEDED}" ] && [ -s /etc/ssl/certs/cacert.pem ] ; then
export CURL_SSL="--cacert ${CACERT_PEM}"
fi
download_file "/dev/null" "https://raw.githubusercontent.com/MiSTer-devel/Downloader_MiSTer/main/downloader.sh"
fi
else
Expand Down

0 comments on commit 103efb4

Please sign in to comment.