Compare commits

...

2 commits

View file

@ -87,7 +87,9 @@ function _machines-regenKey {
function _machines-verifyCertificate { function _machines-verifyCertificate {
if openssl verify $MACHINES_CONFIG/machines.crt | grep -v 'error18' | grep 'error' --quiet; then if openssl verify $MACHINES_CONFIG/machines.crt | grep -v 'error18' | grep 'error' --quiet; then
echo "Invalid certificate" echo "Invalid certificate"
exit 1 return 1
else
return 0
fi fi
} }
@ -102,13 +104,17 @@ function _machines-ensurePub {
mv $CERT_FILE $MACHINES_CONFIG/machines.crt &> /dev/null mv $CERT_FILE $MACHINES_CONFIG/machines.crt &> /dev/null
else else
echo "Certificate rejected." echo "Certificate rejected."
exit 1 return 1
fi fi
fi fi
_machines-verifyCertificate _machines-verifyCertificate
if [ $? != 0 ]; then
return 1
fi
if [ ! -f $MACHINES_CONFIG/machines.pub ]; then if [ ! -f $MACHINES_CONFIG/machines.pub ]; then
_machines-pubFromCrt _machines-pubFromCrt
fi fi
return 0
} }
# SSH ACCESS KEYS # SSH ACCESS KEYS
@ -124,6 +130,9 @@ function _machines-signAkey { # network
function _machines-getAkey { # network function _machines-getAkey { # network
_machines-ensurePub _machines-ensurePub
if [ $? != 0 ]; then
return 1
fi
KEY_FILE=$(mktemp) KEY_FILE=$(mktemp)
SIGN_FILE=$(mktemp) SIGN_FILE=$(mktemp)
_machines-api akey/$1 > $KEY_FILE _machines-api akey/$1 > $KEY_FILE
@ -284,6 +293,9 @@ function machines-setup {
fi fi
_machines-ensurePub _machines-ensurePub
if [ $? != 0 ]; then
return 1
fi
# Variables # Variables
read -p 'Machine name? ' name read -p 'Machine name? ' name