Skip to content

Commit 1951142

Browse files
committed
fix: use homeassistant.local as cert hostname instead of dynamic IP
Using IP as cert CN was fragile — IP can change (DHCP) and vary per installation. homeassistant.local is always valid on local networks via mDNS and is stable regardless of IP assignment. Users should browse to https://homeassistant.local:4430 or http://homeassistant.local:4431 (auto-redirect to HTTPS). Also removes unused HA_IP variable from startup log. Bump version to 0.2.10.
1 parent 4680780 commit 1951142

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

meshcentral/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MeshCentral",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"slug": "meshcentral",
55
"description": "Self-hosted remote device management — monitor and control your PCs from Home Assistant",
66
"url": "https://github.com/andlo/ha-meshcentral-addon",

meshcentral/run.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ if bashio::config.has_value 'hostname'; then
2525
HOSTNAME=$(bashio::config 'hostname')
2626
fi
2727

28-
# Get HA's local IP for cert — this is what users browse to
29-
HA_IP=$(bashio::info.ip_address 2>/dev/null || echo "")
30-
3128
bashio::log.info "Starting MeshCentral..."
3229
bashio::log.info "Server mode: ${SERVER_MODE}"
3330
bashio::log.info "Hostname: ${HOSTNAME}"
34-
if [ -n "$HA_IP" ]; then
35-
bashio::log.info "IP address: ${HA_IP}"
36-
fi
3731

3832
mkdir -p "${DATA_PATH}" "${FILES_PATH}" "${BACKUP_PATH}" "${RECORDINGS_PATH}"
3933

@@ -60,12 +54,14 @@ fi
6054
# Ports — MeshCentral listens directly on external ports to avoid origin mismatch
6155
SETTINGS=$(echo "$SETTINGS" | jq '. + {port: 4430, redirPort: 4431, mpsPort: 4433}')
6256

63-
# Cert — set to HA IP so MeshCentral's origin check matches what the browser sends
57+
# Cert — determines what hostname MeshCentral uses for its certificate
58+
# and origin validation. Use cert_url if set (external), otherwise
59+
# homeassistant.local which works on any local network without knowing IP.
6460
if bashio::config.has_value 'cert_url'; then
6561
CERT_HOST=$(bashio::config 'cert_url' | sed 's|https://||' | sed 's|http://||' | sed 's|/.*||')
6662
SETTINGS=$(echo "$SETTINGS" | jq --arg v "$CERT_HOST" '. + {cert: $v}')
67-
elif [ -n "$HA_IP" ]; then
68-
SETTINGS=$(echo "$SETTINGS" | jq --arg v "$HA_IP" '. + {cert: $v}')
63+
else
64+
SETTINGS=$(echo "$SETTINGS" | jq --arg v "homeassistant.local" '. + {cert: $v}')
6965
fi
7066
SETTINGS=$(echo "$SETTINGS" | jq --argjson v "$TLS_OFFLOAD" '. + {tlsOffload: $v}')
7167

@@ -173,16 +169,12 @@ fi
173169

174170
# ── Start MeshCentral ─────────────────────────────────────────────────────────
175171

176-
HA_IP=$(bashio::info.ip_address 2>/dev/null || echo "homeassistant.local")
177-
HTTPS_PORT=$(bashio::addon.port "443/tcp" 2>/dev/null || echo "4430")
178-
HTTP_PORT=$(bashio::addon.port "80/tcp" 2>/dev/null || echo "4431")
179-
180172
bashio::log.info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
181173
bashio::log.info " MeshCentral is starting..."
182174
bashio::log.info " Open in browser (accept certificate warning):"
183-
bashio::log.info " https://${HA_IP}:${HTTPS_PORT}"
175+
bashio::log.info " https://homeassistant.local:4430"
184176
bashio::log.info " Or via HTTP redirect:"
185-
bashio::log.info " http://${HA_IP}:${HTTP_PORT}"
177+
bashio::log.info " http://homeassistant.local:4431"
186178
bashio::log.info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
187179

188180
bashio::log.info "Starting MeshCentral node process..."

0 commit comments

Comments
 (0)