forked from toniebox-reverse-engineering/teddycloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request toniebox-reverse-engineering#276 from marco79cgn/m…
…aster added shell script to check and verifiy all server and client certificates
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |