mirror of
https://github.com/loewexy/pdns-client
synced 2024-05-06 13:36:32 +02:00
Added keyfile resolving
This commit is contained in:
parent
9782bbd6f9
commit
ec25ca348a
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pdns.private.pem
|
||||||
|
pdns.public.pem
|
24
pdns-client
24
pdns-client
|
@ -1,10 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
SERVER=""
|
SERVER=""
|
||||||
DOMAIN=""
|
DOMAIN=""
|
||||||
ID=""
|
ID=""
|
||||||
CONTENT=""
|
CONTENT=""
|
||||||
KEY="pdns.private.pem"
|
KEY=""
|
||||||
|
|
||||||
exit_error() {
|
exit_error() {
|
||||||
echo "ERROR: ${1}" >&2
|
echo "ERROR: ${1}" >&2
|
||||||
|
@ -50,12 +52,23 @@ validate_arguments() {
|
||||||
then
|
then
|
||||||
exit_error "The content cannot be empty"
|
exit_error "The content cannot be empty"
|
||||||
fi
|
fi
|
||||||
if [[ ! -f "$KEY" ]]
|
}
|
||||||
|
|
||||||
|
resolve_keyfile() {
|
||||||
|
if [ -n "$KEY" ]
|
||||||
then
|
then
|
||||||
exit_error "$KEY is not a file"
|
openssl rsa -in "$KEY" -check -noout > /dev/null 2>&1 || exit_error "$KEY ist not a valid rsa private key"
|
||||||
|
else
|
||||||
|
if openssl rsa -in "pdns.private.pem" -check -noout >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
KEY="pdns.private.pem"
|
||||||
|
elif openssl rsa -in "$SD/pdns.private.pem" -check -noout >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
KEY="$SD/pdns.private.pem"
|
||||||
|
else
|
||||||
|
exit_error "No valid key found. Make shure it is in pdns.private.pem or supply it with -k."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
openssl rsa -in "$KEY" -check -noout > /dev/null 2>&1 || exit_error "$KEY ist not a valid rsa private key"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#main
|
#main
|
||||||
|
@ -85,6 +98,7 @@ done
|
||||||
|
|
||||||
check_dependencies
|
check_dependencies
|
||||||
validate_arguments
|
validate_arguments
|
||||||
|
resolve_keyfile
|
||||||
|
|
||||||
#Get nonce for signing
|
#Get nonce for signing
|
||||||
read NONCE < <(echo "{}" |\
|
read NONCE < <(echo "{}" |\
|
||||||
|
|
Loading…
Reference in a new issue