fix: 🚑 Fix broken cert/key requests
parent
beea0a81d6
commit
12b2c4c1ae
4
USAGE.md
4
USAGE.md
|
@ -87,9 +87,9 @@ To prevent this, a token is generated on the server and sent to the user when re
|
||||||
|
|
||||||
- **REQUEST:** `GET /ssl`
|
- **REQUEST:** `GET /ssl`
|
||||||
- **FILE:** `back/lib/dashboard/ssl`
|
- **FILE:** `back/lib/dashboard/ssl`
|
||||||
- **QUERYSTRING:** `?host=myhostname&ext=crt`
|
- **QUERYSTRING:** `?host=myhostname&type=cert`
|
||||||
- `host`: get file for which host?
|
- `host`: get file for which host?
|
||||||
- `ext`: `crt` for certs or `key` for keys
|
- `type`: `cert` for certs or `key` for keys
|
||||||
- **RESPONSE:** The requested SSL certificate or key file
|
- **RESPONSE:** The requested SSL certificate or key file
|
||||||
|
|
||||||
## 2. Admin service
|
## 2. Admin service
|
||||||
|
|
|
@ -2,25 +2,25 @@
|
||||||
# FILE: dashboard/ssl
|
# FILE: dashboard/ssl
|
||||||
# DESCRIPTION: Get a user's SSL certs and keys
|
# DESCRIPTION: Get a user's SSL certs and keys
|
||||||
# USAGE: ssl remote_ip querystring
|
# USAGE: ssl remote_ip querystring
|
||||||
# QUERYSTRING: ?host=$hostname&ext=crt
|
# QUERYSTRING: ?host=$hostname&type=cert
|
||||||
|
|
||||||
source /etc/wagon/config
|
source /etc/wagon/config
|
||||||
ip="${1}"; qs="$(<<<"${2}" tr '&' '\n' | sed 's/?//')"
|
ip="${1}"; qs="$(<<<"${2}" tr '&' '\n' | sed 's/?//')"
|
||||||
|
|
||||||
# Parse querystring
|
# Parse querystring
|
||||||
hostname="$(<<<"${qs}" grep -oP 'host=(.*)' | sed 's/^host=//' | xargs)"
|
hostname="$(<<<"${qs}" grep -oP 'host=(.*)' | sed 's/^host=//' | xargs)"
|
||||||
ext="$(<<<"${qs}" grep -oP 'ext=(.*)' | sed 's/^ext=//' | xargs)"
|
type="$(<<<"${qs}" grep -oP 'type=(.*)' | sed 's/^type=//' | xargs)"
|
||||||
|
|
||||||
if ! file="${hostname:?}/server.${ext:?}"; then
|
# Make sure type is 'cert' or 'key'
|
||||||
printf 'ERROR! Hostname "%s" or extension "%s" missing!\n' "${hostname}" "${ext}" >&2
|
if [ "${type}" != 'cert' ] && [ "${type}" != 'key' ]; then
|
||||||
printf 'Hostname or extension missing!\n' | /usr/lib/wagon/http_res 400; exit
|
printf 'Invalid type: %s\n' "${type}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit
|
||||||
else
|
|
||||||
printf 'User %s requested SSL file %s\n' "${ip}" "${file}" >&2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure extension is 'crt' or 'key'
|
if ! file="${hostname:?}/${type:?}.pem"; then
|
||||||
if [ "${ext}" != 'crt' ] && [ "${ext}" != 'key' ]; then
|
printf 'ERROR! Hostname "%s" or type "%s" missing!\n' "${hostname}" "${type}" >&2
|
||||||
printf 'Invalid extension: %s\n' "${ext}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit
|
printf 'Hostname or type missing!\n' | /usr/lib/wagon/http_res 400; exit
|
||||||
|
else
|
||||||
|
printf 'User %s requested SSL file %s\n' "${ip}" "${file}" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get username
|
# Get username
|
||||||
|
|
|
@ -9,8 +9,8 @@ function Peer(data) {
|
||||||
this.cantDelete = data.cantDelete
|
this.cantDelete = data.cantDelete
|
||||||
this.isDeleting = ko.observable(false)
|
this.isDeleting = ko.observable(false)
|
||||||
this.deleteText = ko.computed(() => this.isDeleting()?'Deleting...':'Delete')
|
this.deleteText = ko.computed(() => this.isDeleting()?'Deleting...':'Delete')
|
||||||
this.crtHref = ko.computed(() => `${API_URL}/ssl?host=${this.name}&ext=crt`)
|
this.crtHref = ko.computed(() => `${API_URL}/ssl?host=${this.name}&type=cert`)
|
||||||
this.keyHref = ko.computed(() => `${API_URL}/ssl?host=${this.name}&ext=key`)
|
this.keyHref = ko.computed(() => `${API_URL}/ssl?host=${this.name}&type=key`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function PeerList() {
|
function PeerList() {
|
||||||
|
|
Loading…
Reference in New Issue