Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update install.sh - add flag for skipping SSL certificate verificatio… #32

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ http_download_curl() {
local_file=$1
source_url=$2
header=$3
insecure_opt=""
[ "$INSECURE" = "1" ] && insecure_opt="-k"

if [ -z "$header" ]; then
code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url")
code=$(curl $insecure_opt -w '%{http_code}' -sL -o "$local_file" "$source_url")
else
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
code=$(curl $insecure_opt -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
fi
if [ "$code" != "200" ]; then
log_debug "http_download_curl received HTTP status $code"
Expand All @@ -115,10 +118,13 @@ http_download_wget() {
local_file=$1
source_url=$2
header=$3
insecure_opt=""
[ "$INSECURE" = "1" ] && insecure_opt="--no-check-certificate"

if [ -z "$header" ]; then
wget -q -O "$local_file" "$source_url"
wget $insecure_opt -q -O "$local_file" "$source_url"
else
wget -q --header "$header" -O "$local_file" "$source_url"
wget $insecure_opt -q --header "$header" -O "$local_file" "$source_url"
fi
}

Expand Down Expand Up @@ -253,11 +259,14 @@ Usage: $this [-b] bin_dir [-d] [tag] [-x]
[tag] A tag from https://github.com/orcasecurity/orca-cli/releases
In case a tag is missing, latest tag will be used.
-x enables a mode of the shell where all executed commands are printed to the terminal.
-k Skip SSL certificate verification when downloading

EOF
exit 2
}

INSECURE=0

parse_args() {
# BINDIR default value is /usr/local/bin unless set be ENV
# or over-ridden by flag below
Expand All @@ -267,12 +276,14 @@ parse_args() {
else
BINDIR=${BINDIR:-/usr/local/bin}
fi
while getopts "b:dh?x" arg; do
while getopts "b:dh?xk" arg; do
log_info "checking $arg"
case "$arg" in
b) BINDIR="$OPTARG" ;;
d) log_set_priority 10 ;;
h | \?) usage "$0" ;;
x) set -x ;;
k) INSECURE=1 ;;
esac
done

Expand Down Expand Up @@ -421,4 +432,3 @@ main(){
}

main "${@}"