diff --git a/back/lib/dashboard/ssl b/back/lib/dashboard/ssl index 3b82028..f32f694 100755 --- a/back/lib/dashboard/ssl +++ b/back/lib/dashboard/ssl @@ -11,11 +11,7 @@ ip="${1}"; qs="$(<<<"${2}" tr '&' '\n' | sed 's/?//')" hostname="$(<<<"${qs}" grep -oP 'host=(.*)' | sed 's/^host=//' | xargs)" type="$(<<<"${qs}" grep -oP 'type=(.*)' | sed 's/^type=//' | xargs)" -# Make sure type is 'cert' or 'key' -if [ "${type}" != 'cert' ] && [ "${type}" != 'key' ]; then - printf 'Invalid type: %s\n' "${type}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit -fi - +# Check args exist if ! file="${hostname:?}/${type:?}.pem"; then printf 'ERROR! Hostname "%s" or type "%s" missing!\n' "${hostname}" "${type}" >&2 printf 'Hostname or type missing!\n' | /usr/lib/wagon/http_res 400; exit @@ -23,6 +19,11 @@ else printf 'User %s requested SSL file %s\n' "${ip}" "${file}" >&2 fi +# Make sure type is 'cert' or 'key' +if [ "${type}" != 'cert' ] && [ "${type}" != 'key' ]; then + printf 'Invalid type: %s\n' "${type}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit +fi + # Get username if ! domain="$(/usr/lib/wagon/ns_lookup_rdns "${ip}")"; then printf 'ERROR! Failed to lookup domain from user IP %s\n' "${ip}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 500