Certificate exporter/uploader

Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
Georg Pfuetzenreuter 2021-09-27 00:36:31 +02:00
parent 8e1b0658fd
commit 8136cb2963
Signed by: Georg
GPG Key ID: 1DAF57F49F8E8F22
1 changed files with 61 additions and 4 deletions

View File

@ -239,6 +239,7 @@ certman() {
--menu "" 0 0 8 \
"1" "Manage Certificate Authority" \
"2" "Manage Client Certificates" \
"3" "Create new client certificate" \
2>&1 1>&3)
exec 3>&-
case $certmansel in
@ -248,6 +249,9 @@ certman() {
2 )
get_certs
;;
3 )
add_cert
;;
esac
}
@ -304,10 +308,10 @@ get_certs() {
CRTRADIOLIST="$CRTRADIOLIST $CRTFILENAME $CRTFILENAME off"
let CRTCOUNTER=CRTCOUNTER+1
done
crt_choice=$(dialog --ok-label "Delete" \
crt_choice=$(dialog --ok-label "View" \
--cancel-label "Back" \
--extra-button \
--extra-label "New Certificate" \
--extra-label "Delete" \
--title "Client Certificates" \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--radiolist "Manage your client certificates:" 0 0 $CRTCOUNTER \
@ -315,9 +319,21 @@ get_certs() {
2>&1 1>&3)
exit_status=$?
case $exit_status in
0) remove_cert "$crt_choice"
0)
if [ ! $crt_choice = "" ]; then
get_cert "$crt_choice"
else
get_certs
fi
;;
3) add_cert
1) certman
;;
3)
if [ ! $crt_choice = "" ]; then
remove_cert "$crt_choice"
else
get_certs
fi
;;
esac
exec 3>&-
@ -341,6 +357,47 @@ get_certs() {
exec 3>&-
}
get_cert() {
cert=$1
sha1=$(openssl x509 -noout -fingerprint -sha1 -in $pouncedir/users/$USER/certs/$cert)
sha256=$(openssl x509 -noout -fingerprint -sha256 -in $pouncedir/users/$USER/certs/$cert)
dialog \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--title "Fingerprints" \
--ok-label "Back" \
--extra-button \
--extra-label "Download" \
--msgbox "$sha1\n\n$sha256" 10 90
exit_status=$?
case $exit_status in
0 )
get_certs
;;
3 )
if [ ! $cert = "" ]; then
export_cert "$cert"
fi
;;
esac
}
export_cert() {
cert=$1
exec 3>&1
pbincli send -f $pouncedir/users/$USER/certs/$cert -B -q | grep -o "https://.*" | dialog \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--title "Certificate Download" \
--programbox "One-time download for client certificate $cert:" \
5 150
exit_status=$?
case $exit_status in
0 )
get_certs
;;
esac
exec 3>&-
}
add_cert() {
exec 3>&1
crt_input=$(dialog --ok-label "Submit" \