Skip to content

Commit ff0efbe

Browse files
committed
Allow use of hostname instead of local IP
1 parent ff73137 commit ff0efbe

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

run-issuer.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
#!/usr/bin/env bash
22

3-
HOST_IP=$(<.config.ip)
3+
if [ -f ".config.hostname" ]; then
4+
HOST=$(<.config.hostname)
5+
elif [ -f ".config.ip" ]; then
6+
HOST=$(<.config.ip)
7+
else
8+
echo "Missing server setup, run setup_issuer.sh"
9+
exit
10+
fi
411

512
source .venv/bin/activate
613
export REQUESTS_CA_BUNDLE=$(realpath iaca.pem)
7-
export SERVICE_URL="https://${HOST_IP}:5000/"
14+
export SERVICE_URL="https://${HOST}:5000/"
815
export EIDAS_NODE_URL="https://TODO1/"
916
export DYNAMIC_PRESENTATION_URL="https://TODO2/"
1017

11-
flask --app app run --cert=cert.pem --key=key.pem --host="$HOST_IP"
18+
flask --app app run --cert=cert.pem --key=key.pem --host="$HOST"

scripts/setup-cert.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ function install_certificates() {
3535

3636
function generate_config_file()
3737
{
38+
if [ "${HOSTNAME}" != "" ]; then
39+
DNS_ALT_NAME="DNS.1 = ${HOSTNAME}"
40+
else
41+
DNS_ALT_NAME=""
42+
fi
3843
cat << EOF
3944
[req]
4045
default_bits = 2048
@@ -63,7 +68,8 @@ extendedKeyUsage = serverAuth, clientAuth, codeSigning, emailProtection
6368
subjectAltName = @alt_names
6469
6570
[alt_names]
66-
IP.1 = ${LOCAL_ADDR}
71+
IP.1 = ${IP}
72+
${DNS_ALT_NAME}
6773
EOF
6874
}
6975

@@ -113,21 +119,36 @@ function generate_ssl_certificate() {
113119

114120
if [ $CUSTOM_ROOT_CA -eq 1 ]; then
115121
echo "== Verifying the certificate using root CA ${LOCAL_ROOT_CA} =="
116-
openssl verify -CAfile ${LOCAL_ROOT_CA} -purpose sslserver -verify_ip ${LOCAL_ADDR} ${CRT}
122+
openssl verify -CAfile ${LOCAL_ROOT_CA} -purpose sslserver -verify_ip ${IP} ${CRT}
117123
fi
118124
}
119125

120126
if [ "$1" == "-h" ]; then
121127
echo "Set up the certificate of the issuer"
122-
echo "Usage: setup-cert.sh [LOCAL_IP]"
128+
echo "Usage: setup-cert.sh [IP] [HOSTNAME]"
123129
exit
124-
elif [ "$1" == "" ]; then
130+
fi
131+
132+
# IP setup
133+
rm -f .config.ip
134+
if [ "$1" == "" ]; then
125135
echo $(./resolve-ip.sh) > .config.ip
126136
else
127137
echo $1 > .config.ip
128138
fi
129-
130-
LOCAL_ADDR=$(cat .config.ip)
139+
IP=$(cat .config.ip)
140+
141+
# Hostname setup
142+
rm -f .config.hostname
143+
if [ "$2" != "" ]; then
144+
HOSTNAME=$2
145+
LOCAL_ADDR=${HOSTNAME}
146+
echo "Using local hostname: ${LOCAL_ADDR}"
147+
echo ${LOCAL_ADDR} > .config.hostname
148+
else
149+
HOSTNAME=
150+
LOCAL_ADDR=${IP}
151+
fi
131152
echo "Using local address: ${LOCAL_ADDR}"
132153

133154
generate_ssl_certificate

scripts/setup-issuer-metadata.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22

33
if [ "$1" == "-h" ]; then
4-
echo "Usage: setup-issuer-metadata.sh [IP]"
4+
echo "Usage: setup-issuer-metadata.sh [ISSUER]"
55
echo
6-
echo "IP the local IP of the issuer, empty for autodetection"
6+
echo "IP the local IP/hostname of the issuer, empty for IP autodetection"
77
exit
88
elif [ "$1" == "" ]; then
9-
IP=$(cat .config.ip)
9+
LOCAL_ADDR=$(cat .config.ip)
1010
else
11-
IP=$1
11+
LOCAL_ADDR=$1
1212
fi
1313

1414
git restore app/metadata_config/metadata_config.json app/metadata_config/oauth-authorization-server.json app/metadata_config/openid-configuration.json
15-
git grep issuer.eudiw.dev | fgrep --color=none .json | cut -d ':' -f 1 | sort -u | xargs sed -i -e "s/https:\/\/issuer.eudiw.dev/https:\/\/${IP}:5000/g"
15+
git grep issuer.eudiw.dev | fgrep --color=none .json | cut -d ':' -f 1 | sort -u | xargs sed -i -e "s/https:\/\/issuer.eudiw.dev/https:\/\/${LOCAL_ADDR}:5000/g"

setup-issuer.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#!/usr/bin/env bash
22

33
if [ "$1" == "-h" ]; then
4-
echo "Usage: setup-issuer.sh [IP]"
4+
echo "Usage: setup-issuer.sh [IP] [HOSTNAME]"
55
echo
6-
echo "IP the local IP of the issuer, empty for autodetection"
6+
echo "IP the local IP of the issuer, empty for autodetection"
7+
echo "HOSTNAME the hostname of the issuer (optional)"
78
exit
89
fi
910

1011
./scripts/setup-venv.sh
11-
./scripts/setup-cert.sh $1
12+
./scripts/setup-cert.sh $1 $2
1213
cp app/app_config/__config_secrets.py app/app_config/config_secrets.py
1314

14-
./scripts/setup-issuer-metadata.sh $1
15+
if [ "$2" != "" ]; then
16+
ISSUER_LOCATION=$2
17+
else
18+
ISSUER_LOCATION=$1
19+
fi
20+
./scripts/setup-issuer-metadata.sh ${ISSUER_LOCATION}

0 commit comments

Comments
 (0)