Skip to content

Commit

Permalink
Merge pull request toniebox-reverse-engineering#276 from marco79cgn/m…
Browse files Browse the repository at this point in the history
…aster

added shell script to check and verifiy all server and client certificates
  • Loading branch information
SciLor authored Dec 21, 2024
2 parents afe6a66 + 939283e commit fac6888
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions contrib/verify-tc-certificates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
certs_path="/teddycloud/certs"
echo "-----------------------------------"
echo "Checking teddyCloud certificates..."
echo "-----------------------------------"

# check server and default client certs
files=( "server/ca.der" "server/ca-key.pem" "server/ca-root.pem" "client/ca.der" "client/client.der" "client/private.der" )
for file in "${files[@]}"
do
filename=$(echo -en "$file: ")
status=$([ -f "$certs_path/$file" ] && echo -e "\e[32mOK\e[0m" || echo -e "\e[31mFile not found!\e[0m")
# TeddyCloud CA validation
if [[ $file == "server/ca.der" ]]; then
if [ -f "$certs_path/$file" ] && [ $(cat "$certs_path/$file" | grep -c "Teddy.* CA") -eq 0 ]; then
status=$(echo -e "\e[31mWrong server CA, not from Teddycloud!\e[0m")
fi
fi
# Boxine CA validation
if [[ $file == "client/ca.der" ]]; then
if [ -f "$certs_path/$file" ] && [ $(cat "$certs_path/$file" | grep -c "Boxine CA") -eq 0 ]; then
status=$(echo -e "\e[31mWrong client CA, not from Boxine!\e[0m")
fi
fi
printf "%-26s %-10s\n" "$filename" "$status"
done

# check client certs for each box
client_files=( "ca.der" "client.der" "private.der" )
for dir in $certs_path/client/*/
do
box_path=${dir%*/}
box_id=${box_path##*/}
for file in "${client_files[@]}"
do
filename=$(echo -en "$box_id/$file: ")
status=$([ -f "$box_path/$file" ] && echo -e "\e[32mOK\e[0m" || echo -e "\e[31mFile not found!\e[0m")
# Boxine CA validation
if [[ $file == "ca.der" ]]; then
if [ -f "$box_path/$file" ] && [ $(cat "$box_path/$file" | grep -c "Boxine CA") -eq 0 ]; then
status=$(echo -e "\e[31mWrong client CA, not from Boxine!\e[0m")
fi
fi
printf "%-26s %-10s\n" "$filename" "$status"
done
done

0 comments on commit fac6888

Please sign in to comment.