Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fff51841a | |||
| e5478ed5ef | |||
| 084d7d65e0 | |||
| 62d571b0d7 | |||
| 97d5f4ed48 | |||
| 2b42f58803 | |||
| f53f2f6309 | |||
| 03cd5ee028 | |||
| fff4b994e1 | |||
| 13c399133c | |||
| 940a41669f | |||
| e9b43da768 | |||
| c14b628558 | |||
| a502aa0128 | |||
| e0b7ead458 | |||
| b5dcf2d815 | |||
| 1d33b8d3f3 | |||
| d592dc6db0 | |||
| bc4d7fea39 | |||
| 5b7d8c3927 | |||
| edb2a6df1d | |||
| bea370dca2 | |||
| 7772e489e0 | |||
| 2e50696bb4 | |||
| 25f3a40402 | |||
| 2bfe130d3b | |||
| 3cd04e3263 | |||
| 00cc2beec7 | |||
| 9472cfff8d | |||
| e23eb7498b | |||
| 5098a5d510 | |||
| 320098dd76 | |||
| 1d185f5d6c |
@@ -21,15 +21,29 @@
|
|||||||
# tag's commit is actually part of main's history (see check-branch job).
|
# tag's commit is actually part of main's history (see check-branch job).
|
||||||
|
|
||||||
name: build-and-push
|
name: build-and-push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "mqtt-cert-manager/v*"
|
||||||
|
- "visquitto/v*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
addon:
|
||||||
|
description: "Which add-on to build"
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- mqtt-cert-manager
|
||||||
|
- visquitto
|
||||||
|
version:
|
||||||
|
description: "Version (e.g. 0.4.0) — leave empty to read from config.yaml"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY_HOST: gitea.viratak.com
|
REGISTRY_HOST: gitea.viratak.com
|
||||||
REGISTRY_OWNER: bitopa
|
REGISTRY_OWNER: bitopa
|
||||||
IMAGE_NAME: mqtt-cert-manager
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-branch:
|
check-branch:
|
||||||
@@ -42,12 +56,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Make sure we have main's history too
|
- name: Make sure we have main's history
|
||||||
run: git fetch origin main:refs/remotes/origin/main
|
run: git fetch origin main:refs/remotes/origin/main
|
||||||
|
|
||||||
- name: Is this tag's commit part of main?
|
- name: Is this tag's commit part of main?
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
echo "on_main=true" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if git merge-base --is-ancestor HEAD origin/main; then
|
if git merge-base --is-ancestor HEAD origin/main; then
|
||||||
echo "on_main=true" >> "$GITHUB_OUTPUT"
|
echo "on_main=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -55,17 +74,56 @@ jobs:
|
|||||||
echo "Tag $GITHUB_REF_NAME points to a commit that is not on main — skipping build."
|
echo "Tag $GITHUB_REF_NAME points to a commit that is not on main — skipping build."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build:
|
prepare:
|
||||||
needs: check-branch
|
needs: check-branch
|
||||||
if: needs.check-branch.outputs.on_main == 'true'
|
if: needs.check-branch.outputs.on_main == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
addon: ${{ steps.meta.outputs.addon }}
|
||||||
|
version: ${{ steps.meta.outputs.version }}
|
||||||
|
image: ${{ steps.meta.outputs.image }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Determine add-on and version
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
ADDON="${{ inputs.addon }}"
|
||||||
|
VERSION="${{ inputs.version }}"
|
||||||
|
else
|
||||||
|
# tag format: mqtt-cert-manager/v0.3.0 or visquitto/v0.4.0
|
||||||
|
ADDON=$(echo "${{ github.ref_name }}" | cut -d/ -f1)
|
||||||
|
VERSION=$(echo "${{ github.ref_name }}" | cut -d/ -f2 | sed 's/^v//')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fallback: read version from config.yaml if not provided
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
VERSION=$(grep '^version:' "$ADDON/config.yaml" | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$ADDON" ] || [ -z "$VERSION" ]; then
|
||||||
|
echo "Could not determine add-on or version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "addon=$ADDON" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "image=${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/$ADDON" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "Building $ADDON version $VERSION"
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: prepare
|
||||||
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- arch: amd64
|
- arch: amd64
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
# TEMPORARY: only building amd64 while developing against a
|
# Uncomment when you are ready for multi-arch:
|
||||||
# single Dell thin client — restore these before publishing.
|
|
||||||
# - arch: aarch64
|
# - arch: aarch64
|
||||||
# platform: linux/arm64
|
# platform: linux/arm64
|
||||||
# - arch: armv7
|
# - arch: armv7
|
||||||
@@ -78,24 +136,8 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Read add-on version
|
# - name: Set up QEMU
|
||||||
id: version
|
# uses: docker/setup-qemu-action@v3
|
||||||
# Plain shell instead of python3+PyYAML: the runner's Python has
|
|
||||||
# no yaml module installed, and this value is a simple one-liner
|
|
||||||
# anyway (version: "0.1.0"), so there's no need for a real YAML
|
|
||||||
# parser or an extra apt/pip install step just for this.
|
|
||||||
run: |
|
|
||||||
VERSION=$(grep '^version:' mqtt-cert-manager/config.yaml | cut -d'"' -f2)
|
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Read base image for this arch from build.yaml
|
|
||||||
id: base
|
|
||||||
run: |
|
|
||||||
BUILD_FROM=$(grep -E "^[[:space:]]*${{ matrix.arch }}:" mqtt-cert-manager/build.yaml | cut -d'"' -f2)
|
|
||||||
echo "build_from=$BUILD_FROM" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Set up QEMU (needed to build non-amd64 targets on an amd64 runner)
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -108,13 +150,12 @@ jobs:
|
|||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./mqtt-cert-manager
|
context: ./${{ needs.prepare.outputs.addon }}
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
# No BUILD_FROM needed anymore — modern Dockerfiles have a direct FROM
|
||||||
BUILD_FROM=${{ steps.base.outputs.build_from }}
|
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:${{ steps.version.outputs.version }}
|
${{ needs.prepare.outputs.image }}-${{ matrix.arch }}:${{ needs.prepare.outputs.version }}
|
||||||
${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_OWNER }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}:latest
|
${{ needs.prepare.outputs.image }}-${{ matrix.arch }}:latest
|
||||||
@@ -4,7 +4,7 @@ App/add-on repository for [Viratak](https://viratak.com).
|
|||||||
|
|
||||||
Apps documentation: <https://developers.home-assistant.io/docs/apps>
|
Apps documentation: <https://developers.home-assistant.io/docs/apps>
|
||||||
|
|
||||||
[](https://my.home-assistant.io/redirect/supervisor_store/?repository_url=https://gitea.viratak.com/eta/virarepo)
|
[](https://my.home-assistant.io/redirect/supervisor_store/?repository_url=https://gitea.viratak.com/bitopa/virarepo)
|
||||||
|
|
||||||
## Apps
|
## Apps
|
||||||
|
|
||||||
@@ -17,6 +17,13 @@ This repository contains the following apps
|
|||||||
|
|
||||||
_Application to use as a certificate manager for Home Assistant._
|
_Application to use as a certificate manager for Home Assistant._
|
||||||
|
|
||||||
|
### [Visquitto](./visquitto)
|
||||||
|
|
||||||
|
<!-- ![Supports aarch64 Architecture][aarch64-shield] -->
|
||||||
|
![Supports amd64 Architecture][amd64-shield]
|
||||||
|
|
||||||
|
_Application to use as a Second MQTT broker._
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
Notes to developers after forking or using the github template feature:
|
Notes to developers after forking or using the github template feature:
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.6.0
|
||||||
|
|
||||||
|
- Changed certificate renwal procedure
|
||||||
|
|
||||||
|
## 0.5.2
|
||||||
|
|
||||||
|
- Improved logging and error handling
|
||||||
|
|
||||||
|
## 0.5.1 - 2026-10-11
|
||||||
|
|
||||||
|
- Bug fix
|
||||||
|
|
||||||
|
## 0.5.0 - 2026-10-11
|
||||||
|
|
||||||
|
- Upgraded image build precedure
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
- Certificate Common Name (CN) is now taken from each device's own
|
||||||
|
CSR instead of being forced to equal its `device_id`. Enables
|
||||||
|
deployments where many devices intentionally share one CN per
|
||||||
|
category (e.g. for broker ACL grouping) while each still uses its
|
||||||
|
own unique MQTT topic.
|
||||||
|
- `GET /api/pending` and `GET /api/issued` now include the resolved
|
||||||
|
CN alongside `device_id` for each entry.
|
||||||
|
|
||||||
|
## 0.4.1
|
||||||
|
|
||||||
|
- Changed SAN default for generating server certificate
|
||||||
|
- Added two new options for organizations
|
||||||
|
|
||||||
|
## 0.4.0
|
||||||
|
|
||||||
|
- Replaced RSA algorithm with EC for encryption.
|
||||||
|
|
||||||
|
## 0.3.0
|
||||||
|
|
||||||
|
- Initial release.
|
||||||
@@ -7,17 +7,29 @@ MQTT broker (unauthenticated, or with a shared bootstrap username/password
|
|||||||
|
|
||||||
Default topic prefix is `cert/enroll`, configurable in the add-on options.
|
Default topic prefix is `cert/enroll`, configurable in the add-on options.
|
||||||
Replace `<device_id>` with a stable, unique identifier for the node (e.g.
|
Replace `<device_id>` with a stable, unique identifier for the node (e.g.
|
||||||
its MAC address with colons stripped, or a serial number). This value is
|
its MAC address with colons stripped, or a serial number) — this MUST be
|
||||||
used as both the MQTT topic segment and the certificate's Common Name /
|
unique per physical device, even if many devices share the same MQTT
|
||||||
SAN, so keep it short, DNS-safe, and unique on your network.
|
login for connecting to the broker. It's what topic routing and this
|
||||||
|
add-on's own record-keeping are both keyed on; two devices sharing a
|
||||||
|
`device_id` will collide with each other.
|
||||||
|
|
||||||
|
The cert's Common Name (CN) is a separate, independent concept — see
|
||||||
|
step 2.
|
||||||
|
|
||||||
## 1. Generate a key pair and CSR (on-device, once)
|
## 1. Generate a key pair and CSR (on-device, once)
|
||||||
|
|
||||||
The private key never leaves the device. Generate an RSA-2048 (or EC
|
The private key never leaves the device. Generate an RSA-2048 (or EC
|
||||||
P-256) key pair and a PKCS#10 CSR with:
|
P-256) key pair and a PKCS#10 CSR with:
|
||||||
- Common Name = `<device_id>`
|
|
||||||
- No need for extensions in the CSR itself; the add-on sets the ones that
|
- Common Name = whatever identity you want written into the issued
|
||||||
matter (basic constraints, key usage, SAN) when it signs.
|
certificate. This does NOT have to be `device_id` and does NOT have to
|
||||||
|
be unique per device — a common pattern is to share one CN across a
|
||||||
|
whole category of devices (e.g. every TH sensor uses CN `TH-Sensors`,
|
||||||
|
every light sensor uses CN `Light-Sensors`), which is useful if you're
|
||||||
|
writing broker ACL rules grouped by category rather than by individual
|
||||||
|
device.
|
||||||
|
- No need for other extensions in the CSR itself; the add-on sets the
|
||||||
|
ones that matter (basic constraints, key usage, SAN) when it signs.
|
||||||
|
|
||||||
Persist the key pair to flash. If a cert is later lost or expires, reuse
|
Persist the key pair to flash. If a cert is later lost or expires, reuse
|
||||||
the same key and just repeat step 2 — no need to regenerate the key.
|
the same key and just repeat step 2 — no need to regenerate the key.
|
||||||
@@ -28,6 +40,7 @@ Topic: `cert/enroll/<device_id>/request`
|
|||||||
QoS: 1, retain: false
|
QoS: 1, retain: false
|
||||||
|
|
||||||
Payload (JSON):
|
Payload (JSON):
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"csr": "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----\n",
|
"csr": "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----\n",
|
||||||
@@ -37,34 +50,53 @@ Payload (JSON):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`meta` is optional and only shown to the human approving the request — put
|
`meta` is optional and only shown to the human approving the request — put
|
||||||
anything there that helps you recognize the device in the UI.
|
anything there that helps you recognize the device in the UI.
|
||||||
|
|
||||||
|
The issued certificate's CN is taken directly from your CSR's own CN
|
||||||
|
(step 1) — there's no separate field for it here. If your CSR has no CN
|
||||||
|
at all, the add-on falls back to using `device_id` as the CN, but that's
|
||||||
|
a safety net for malformed requests, not something to rely on.
|
||||||
|
|
||||||
|
This does NOT apply to renewal (§5) — a renewed cert always keeps the CN
|
||||||
|
of the device's current, still-valid cert, regardless of what a renewal
|
||||||
|
request's CSR claims. Changing identity requires a fresh, human-approved
|
||||||
|
enrollment, not a renewal.
|
||||||
|
|
||||||
## 3. Subscribe for the result, before or immediately after publishing
|
## 3. Subscribe for the result, before or immediately after publishing
|
||||||
|
|
||||||
Subscribe to both of these (QoS 1) so you catch whichever response comes:
|
Subscribe to both of these (QoS 1) so you catch whichever response comes.
|
||||||
|
Since `device_id` is unique per device (per the requirement above), each
|
||||||
|
device has its own dedicated topics here — no filtering needed, unlike
|
||||||
|
setups where many devices might share one topic.
|
||||||
|
|
||||||
- `cert/enroll/<device_id>/issued` — retained. Payload:
|
- `cert/enroll/<device_id>/issued` — retained. Payload:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"cert": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n",
|
"cert": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n",
|
||||||
"ca": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"
|
"ca": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Because this is retained, if the device subscribes *after* a cert was
|
Because this is retained, if the device subscribes *after* a cert was
|
||||||
already issued (e.g. after a reboot), it will receive it immediately
|
already issued (e.g. after a reboot), it will receive it immediately
|
||||||
without needing to re-request.
|
without needing to re-request.
|
||||||
|
|
||||||
- `cert/enroll/<device_id>/rejected` — not retained. Payload:
|
- `cert/enroll/<device_id>/rejected` — not retained. Payload:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{ "reason": "human-readable reason" }
|
{ "reason": "human-readable reason" }
|
||||||
```
|
```
|
||||||
|
|
||||||
- `cert/enroll/<device_id>/revoked` — not retained, best-effort only.
|
- `cert/enroll/<device_id>/revoked` — not retained, best-effort only.
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{ "reason": "human-readable reason" }
|
{ "reason": "human-readable reason" }
|
||||||
```
|
```
|
||||||
|
|
||||||
Sent if you revoke a device's cert after it was issued. This is
|
Sent if you revoke a device's cert after it was issued. This is
|
||||||
informational — actual enforcement happens at the TLS layer via
|
informational — actual enforcement happens at the TLS layer via
|
||||||
Mosquitto's CRL check, which a revoked device will hit on its *next*
|
Mosquitto's CRL check, which a revoked device will hit on its *next*
|
||||||
@@ -93,6 +125,7 @@ Topic: `cert/enroll/<device_id>/renew`
|
|||||||
QoS: 1, retain: false
|
QoS: 1, retain: false
|
||||||
|
|
||||||
Payload (JSON):
|
Payload (JSON):
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"csr": "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----\n",
|
"csr": "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----\n",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
ARG BUILD_FROM
|
FROM ghcr.io/home-assistant/base:3.24
|
||||||
FROM ${BUILD_FROM}
|
|
||||||
|
|
||||||
RUN apk add --no-cache python3 py3-pip
|
RUN apk add --no-cache python3 py3-pip
|
||||||
|
|
||||||
@@ -12,8 +11,8 @@ COPY run.sh /run.sh
|
|||||||
RUN chmod a+x /run.sh
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
LABEL \
|
LABEL \
|
||||||
io.hass.version="0.1.0" \
|
io.hass.name="MQTT Certificate Manager" \
|
||||||
io.hass.type="addon" \
|
io.hass.type="addon" \
|
||||||
io.hass.arch="armhf|armv7|aarch64|amd64|i386"
|
io.hass.arch="amd64"
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
CMD ["/run.sh"]
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ self-signed CA — no external CA or internet dependency.
|
|||||||
|
|
||||||
Full device-side wire protocol: see `DEVICE_PROTOCOL.md`.
|
Full device-side wire protocol: see `DEVICE_PROTOCOL.md`.
|
||||||
|
|
||||||
## Installing this add-on
|
## Installing this application
|
||||||
|
|
||||||
|
1. Add [virarepo repository](https://gitea.viratak.com/bitopa/virarepo) in applications section
|
||||||
|
2. Look for this project, and click install
|
||||||
|
|
||||||
|
## Offline Installing this application
|
||||||
|
|
||||||
1. Copy this folder into your Home Assistant add-ons repository (or add
|
1. Copy this folder into your Home Assistant add-ons repository (or add
|
||||||
it as a local add-on under `/addons/mqtt_cert_manager` on HAOS).
|
it as a local add-on under `/addons/mqtt_cert_manager` on HAOS).
|
||||||
@@ -42,10 +47,8 @@ Full device-side wire protocol: see `DEVICE_PROTOCOL.md`.
|
|||||||
|
|
||||||
## What's included in this scaffold
|
## What's included in this scaffold
|
||||||
|
|
||||||
- `config.yaml` / `build.yaml` — add-on manifest, current (2026) HA base
|
- `config.yaml` — add-on manifest, current (2026) HA base
|
||||||
image convention. **Double check `build.yaml` against
|
image convention.
|
||||||
https://github.com/home-assistant/docker-base if your Supervisor
|
|
||||||
version is very new or old** — base image tags do change.
|
|
||||||
- `app/ca.py` — root CA generation + CSR signing (RSA-4096 root, 20-year
|
- `app/ca.py` — root CA generation + CSR signing (RSA-4096 root, 20-year
|
||||||
validity; issued certs default to 825 days, matching common CT/browser
|
validity; issued certs default to 825 days, matching common CT/browser
|
||||||
practice, though these are just client certs so it's a soft ceiling you
|
practice, though these are just client certs so it's a soft ceiling you
|
||||||
|
|||||||
+61
-11
@@ -23,20 +23,60 @@ CA_COMMON_NAME = "Home Assistant Local MQTT CA"
|
|||||||
CA_VALIDITY_YEARS = 20
|
CA_VALIDITY_YEARS = 20
|
||||||
|
|
||||||
|
|
||||||
|
def extract_csr_common_name(csr_pem: str):
|
||||||
|
"""Return the CN the CSR itself requests, or None if it has none /
|
||||||
|
doesn't parse. Lets a device declare its own identity independent of
|
||||||
|
whatever MQTT topic segment the request arrived on."""
|
||||||
|
try:
|
||||||
|
csr = x509.load_pem_x509_csr(csr_pem.encode())
|
||||||
|
attrs = csr.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
|
||||||
|
return attrs[0].value if attrs else None
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def extract_cert_common_name(cert_pem: str):
|
||||||
|
"""Return the CN of an already-issued cert, or None if it has none /
|
||||||
|
doesn't parse. Used so renewal can keep a device's identity stable
|
||||||
|
across reissuance regardless of what the new request claims."""
|
||||||
|
try:
|
||||||
|
cert = x509.load_pem_x509_certificate(cert_pem.encode())
|
||||||
|
attrs = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
|
||||||
|
return attrs[0].value if attrs else None
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class CertificateAuthority:
|
class CertificateAuthority:
|
||||||
def __init__(self):
|
def __init__(self, organization: str = "", organizational_unit: str = ""):
|
||||||
|
# Not hardcoded: these come from add-on options (default empty,
|
||||||
|
# meaning "omit entirely" — the subject stays CN-only, same as
|
||||||
|
# before this existed). If set, they're applied consistently to
|
||||||
|
# every cert this CA issues: the root CA itself, the broker cert,
|
||||||
|
# and every device client cert.
|
||||||
|
self.organization = organization
|
||||||
|
self.organizational_unit = organizational_unit
|
||||||
os.makedirs(CA_DIR, exist_ok=True)
|
os.makedirs(CA_DIR, exist_ok=True)
|
||||||
if not (os.path.exists(CA_KEY_PATH) and os.path.exists(CA_CERT_PATH)):
|
if not (os.path.exists(CA_KEY_PATH) and os.path.exists(CA_CERT_PATH)):
|
||||||
self._generate_root_ca()
|
self._generate_root_ca()
|
||||||
self._load_root_ca()
|
self._load_root_ca()
|
||||||
|
|
||||||
|
def _build_name(self, common_name: str) -> x509.Name:
|
||||||
|
attrs = []
|
||||||
|
if self.organization:
|
||||||
|
attrs.append(x509.NameAttribute(NameOID.ORGANIZATION_NAME, self.organization))
|
||||||
|
if self.organizational_unit:
|
||||||
|
attrs.append(
|
||||||
|
x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, self.organizational_unit)
|
||||||
|
)
|
||||||
|
attrs.append(x509.NameAttribute(NameOID.COMMON_NAME, common_name))
|
||||||
|
return x509.Name(attrs)
|
||||||
|
|
||||||
# -- setup ---------------------------------------------------------
|
# -- setup ---------------------------------------------------------
|
||||||
|
|
||||||
def _generate_root_ca(self):
|
def _generate_root_ca(self):
|
||||||
key = rsa.generate_private_key(public_exponent=65537, key_size=4096)
|
key = ec.generate_private_key(ec.SECP256R1())
|
||||||
subject = issuer = x509.Name(
|
subject = issuer = self._build_name(CA_COMMON_NAME)
|
||||||
[x509.NameAttribute(NameOID.COMMON_NAME, CA_COMMON_NAME)]
|
|
||||||
)
|
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
cert = (
|
cert = (
|
||||||
x509.CertificateBuilder()
|
x509.CertificateBuilder()
|
||||||
@@ -95,9 +135,14 @@ class CertificateAuthority:
|
|||||||
def ca_cert_pem(self) -> str:
|
def ca_cert_pem(self) -> str:
|
||||||
return self.cert_pem.decode()
|
return self.cert_pem.decode()
|
||||||
|
|
||||||
def sign_csr(self, csr_pem: str, device_id: str, validity_days: int) -> str:
|
def sign_csr(self, csr_pem: str, common_name: str, validity_days: int) -> str:
|
||||||
"""Validate and sign a device CSR. Returns the signed cert as PEM.
|
"""Validate and sign a device CSR. Returns the signed cert as PEM.
|
||||||
|
|
||||||
|
`common_name` is deliberately NOT tied to any MQTT topic/device_id
|
||||||
|
here -- callers decide where it comes from (see
|
||||||
|
extract_csr_common_name / extract_cert_common_name below, and
|
||||||
|
main.py's resolution order).
|
||||||
|
|
||||||
Raises ValueError on a malformed or untrustworthy CSR.
|
Raises ValueError on a malformed or untrustworthy CSR.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@@ -109,7 +154,7 @@ class CertificateAuthority:
|
|||||||
raise ValueError("CSR signature is invalid")
|
raise ValueError("CSR signature is invalid")
|
||||||
|
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
subject = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, device_id)])
|
subject = self._build_name(common_name)
|
||||||
|
|
||||||
builder = (
|
builder = (
|
||||||
x509.CertificateBuilder()
|
x509.CertificateBuilder()
|
||||||
@@ -139,7 +184,7 @@ class CertificateAuthority:
|
|||||||
critical=False,
|
critical=False,
|
||||||
)
|
)
|
||||||
.add_extension(
|
.add_extension(
|
||||||
x509.SubjectAlternativeName([x509.DNSName(device_id)]),
|
x509.SubjectAlternativeName([x509.DNSName(common_name)]),
|
||||||
critical=False,
|
critical=False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -157,9 +202,9 @@ class CertificateAuthority:
|
|||||||
if not hostnames:
|
if not hostnames:
|
||||||
raise ValueError("at least one hostname/IP is required")
|
raise ValueError("at least one hostname/IP is required")
|
||||||
|
|
||||||
key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
key = ec.generate_private_key(ec.SECP256R1())
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
subject = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, hostnames[0])])
|
subject = self._build_name(hostnames[0])
|
||||||
|
|
||||||
san_entries = []
|
san_entries = []
|
||||||
for name in hostnames:
|
for name in hostnames:
|
||||||
@@ -180,7 +225,12 @@ class CertificateAuthority:
|
|||||||
.add_extension(
|
.add_extension(
|
||||||
x509.KeyUsage(
|
x509.KeyUsage(
|
||||||
digital_signature=True,
|
digital_signature=True,
|
||||||
key_encipherment=True,
|
# key_encipherment only applies to RSA (key-transport)
|
||||||
|
# keys; it's meaningless for an ECDSA key and shouldn't
|
||||||
|
# be set here now that this is EC. ECDHE cipher suites
|
||||||
|
# use ephemeral keys for the actual exchange — this
|
||||||
|
# cert's key is only ever used to sign, not encipher.
|
||||||
|
key_encipherment=False,
|
||||||
content_commitment=False,
|
content_commitment=False,
|
||||||
data_encipherment=False,
|
data_encipherment=False,
|
||||||
key_agreement=False,
|
key_agreement=False,
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
"""
|
||||||
|
Server-issued challenges for certificate renewal.
|
||||||
|
|
||||||
|
Why this exists: a node with no trustworthy clock can't produce a timestamp
|
||||||
|
the server can check, so freshness has to come from the server instead.
|
||||||
|
For each renewal the server hands the node a random, single-use, short-lived
|
||||||
|
nonce, and the node signs that nonce together with a digest of its new CSR.
|
||||||
|
A captured renewal message is useless afterwards: the nonce is gone, and
|
||||||
|
swapping in a different CSR breaks the signature.
|
||||||
|
|
||||||
|
State is in memory only. If the add-on restarts, outstanding challenges are
|
||||||
|
simply lost and the node asks for a new one.
|
||||||
|
"""
|
||||||
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
import secrets
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
from cryptography import x509
|
||||||
|
from cryptography.hazmat.primitives import serialization
|
||||||
|
|
||||||
|
CHALLENGE_TTL_SECONDS = 120
|
||||||
|
|
||||||
|
# Prefix on everything a node signs for renewal. It keeps a renewal
|
||||||
|
# signature from being valid in any other protocol that reuses the key.
|
||||||
|
RENEWAL_CONTEXT = "renew-v1"
|
||||||
|
|
||||||
|
|
||||||
|
def csr_digest(csr_pem: str) -> str:
|
||||||
|
"""SHA-256 (hex) of the CSR's DER encoding. Raises ValueError if the CSR
|
||||||
|
doesn't parse.
|
||||||
|
|
||||||
|
The DER form is hashed, not the PEM text, so line endings or whitespace
|
||||||
|
that differ between the node and the server don't change the result."""
|
||||||
|
csr = x509.load_pem_x509_csr(csr_pem.encode())
|
||||||
|
return hashlib.sha256(csr.public_bytes(serialization.Encoding.DER)).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def renewal_message(device_id: str, nonce: str, digest: str) -> bytes:
|
||||||
|
"""The exact bytes a node signs to prove a renewal request."""
|
||||||
|
return f"{RENEWAL_CONTEXT}|{device_id}|{nonce}|{digest}".encode()
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeStore:
|
||||||
|
"""One active challenge per device. Thread-safe."""
|
||||||
|
|
||||||
|
def __init__(self, ttl: int = CHALLENGE_TTL_SECONDS, clock=time.monotonic):
|
||||||
|
self._ttl = ttl
|
||||||
|
self._clock = clock
|
||||||
|
self._lock = threading.Lock()
|
||||||
|
self._active = {} # device_id -> (nonce, expires_at)
|
||||||
|
|
||||||
|
def _prune(self, now):
|
||||||
|
for device_id in [d for d, (_, exp) in self._active.items() if now >= exp]:
|
||||||
|
del self._active[device_id]
|
||||||
|
|
||||||
|
def issue(self, device_id: str):
|
||||||
|
"""Return (nonce, seconds_left) for this device.
|
||||||
|
|
||||||
|
If the device already has an unexpired challenge, that same one is
|
||||||
|
returned instead of minting another. A node that missed the first
|
||||||
|
message can simply ask again, and nobody else can invalidate a
|
||||||
|
device's challenge by asking for a new one."""
|
||||||
|
with self._lock:
|
||||||
|
now = self._clock()
|
||||||
|
self._prune(now)
|
||||||
|
current = self._active.get(device_id)
|
||||||
|
if current:
|
||||||
|
return current[0], max(1, int(current[1] - now))
|
||||||
|
nonce = secrets.token_hex(32)
|
||||||
|
self._active[device_id] = (nonce, now + self._ttl)
|
||||||
|
return nonce, self._ttl
|
||||||
|
|
||||||
|
def is_active(self, device_id: str, nonce) -> bool:
|
||||||
|
"""Cheap non-consuming check, used to skip signature work for nonces
|
||||||
|
that can't possibly be valid. consume() is the real gate."""
|
||||||
|
with self._lock:
|
||||||
|
current = self._active.get(device_id)
|
||||||
|
if not current or not isinstance(nonce, str):
|
||||||
|
return False
|
||||||
|
stored, expires_at = current
|
||||||
|
if self._clock() >= expires_at:
|
||||||
|
return False
|
||||||
|
return hmac.compare_digest(stored.encode(), nonce.encode())
|
||||||
|
|
||||||
|
def consume(self, device_id: str, nonce) -> bool:
|
||||||
|
"""Atomically check and burn the nonce. True only for the first caller
|
||||||
|
presenting this device's current, unexpired nonce."""
|
||||||
|
with self._lock:
|
||||||
|
current = self._active.get(device_id)
|
||||||
|
if not current:
|
||||||
|
return False
|
||||||
|
stored, expires_at = current
|
||||||
|
if self._clock() >= expires_at:
|
||||||
|
del self._active[device_id]
|
||||||
|
return False
|
||||||
|
if not isinstance(nonce, str) or not hmac.compare_digest(stored.encode(), nonce.encode()):
|
||||||
|
return False
|
||||||
|
del self._active[device_id]
|
||||||
|
return True
|
||||||
+144
-38
@@ -3,24 +3,38 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import sys
|
||||||
|
|
||||||
from flask import Flask, jsonify, render_template, request
|
from flask import Flask, jsonify, render_template, request
|
||||||
|
|
||||||
import store
|
import store
|
||||||
from ca import CertificateAuthority
|
from ca import CertificateAuthority, extract_cert_common_name, extract_csr_common_name
|
||||||
|
from challenges import ChallengeStore, csr_digest, renewal_message
|
||||||
from mqtt_worker import MqttWorker
|
from mqtt_worker import MqttWorker
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(message)s")
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(message)s")
|
||||||
log = logging.getLogger("main")
|
log = logging.getLogger("main")
|
||||||
|
|
||||||
|
|
||||||
|
def _log_uncaught(exc_type, exc, tb):
|
||||||
|
# Python prints uncaught exceptions straight to stderr, bypassing
|
||||||
|
# logging entirely -- which is why a crash traceback had no timestamp
|
||||||
|
# while every other line did. Route it through the logger instead.
|
||||||
|
log.critical("uncaught exception, add-on is exiting", exc_info=(exc_type, exc, tb))
|
||||||
|
|
||||||
|
|
||||||
|
sys.excepthook = _log_uncaught
|
||||||
|
|
||||||
OPTIONS_PATH = "/data/options.json"
|
OPTIONS_PATH = "/data/options.json"
|
||||||
SSL_DIR = "/ssl"
|
SSL_DIR = "/ssl"
|
||||||
BROKER_CERT_FILENAME = "mosquitto-server.crt"
|
BROKER_CERT_FILENAME = "mosquitto-server.crt"
|
||||||
BROKER_KEY_FILENAME = "mosquitto-server.key"
|
BROKER_KEY_FILENAME = "mosquitto-server.key"
|
||||||
CA_FILENAME = "mqtt-cert-manager-ca.crt"
|
CA_FILENAME = "mqtt-cert-manager-ca.crt"
|
||||||
CRL_FILENAME = "mqtt-cert-manager-crl.pem"
|
CRL_FILENAME = "mqtt-cert-manager-crl.pem"
|
||||||
RENEWAL_TIMESTAMP_SKEW_SECONDS = 300
|
|
||||||
|
# Single-use renewal challenges (see challenges.py). Nodes have no clock, so
|
||||||
|
# freshness comes from the server issuing a nonce rather than a timestamp.
|
||||||
|
challenge_store = ChallengeStore()
|
||||||
|
|
||||||
|
|
||||||
def load_options():
|
def load_options():
|
||||||
@@ -31,8 +45,10 @@ def load_options():
|
|||||||
"mqtt_password": "",
|
"mqtt_password": "",
|
||||||
"request_topic_prefix": "cert/enroll",
|
"request_topic_prefix": "cert/enroll",
|
||||||
"cert_validity_days": 825,
|
"cert_validity_days": 825,
|
||||||
"broker_hostnames": "core-mosquitto,localhost",
|
"broker_hostnames": "homeassistant.local,192.168.1.80, core-mosquitto,localhost",
|
||||||
"renewal_window_days": 30,
|
"renewal_window_days": 30,
|
||||||
|
"cert_organization": "",
|
||||||
|
"cert_organizational_unit": "",
|
||||||
}
|
}
|
||||||
if os.path.exists(OPTIONS_PATH):
|
if os.path.exists(OPTIONS_PATH):
|
||||||
with open(OPTIONS_PATH) as f:
|
with open(OPTIONS_PATH) as f:
|
||||||
@@ -41,7 +57,10 @@ def load_options():
|
|||||||
|
|
||||||
|
|
||||||
options = load_options()
|
options = load_options()
|
||||||
ca = CertificateAuthority()
|
ca = CertificateAuthority(
|
||||||
|
organization=options["cert_organization"],
|
||||||
|
organizational_unit=options["cert_organizational_unit"],
|
||||||
|
)
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Guard: this server has no login of its own. It relies entirely on only
|
# Guard: this server has no login of its own. It relies entirely on only
|
||||||
@@ -138,16 +157,31 @@ def write_crl():
|
|||||||
log.info("wrote CRL with %d revoked cert(s) to %s", len(entries), crl_path)
|
log.info("wrote CRL with %d revoked cert(s) to %s", len(entries), crl_path)
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_common_name(device_id: str, csr_pem: str) -> str:
|
||||||
|
"""CN comes from the CSR itself -- devices set it there deliberately,
|
||||||
|
often shared across a whole device category (e.g. all TH sensors use
|
||||||
|
one CN, all light sensors another) for ACL grouping purposes. This
|
||||||
|
is intentionally NOT unique per device, unlike device_id.
|
||||||
|
|
||||||
|
Falls back to device_id only if the CSR has no CN at all (malformed
|
||||||
|
or lazy firmware) -- a safety net, not the intended path."""
|
||||||
|
from_csr = extract_csr_common_name(csr_pem)
|
||||||
|
return from_csr or device_id
|
||||||
|
|
||||||
|
|
||||||
def handle_request(device_id, csr_pem, meta):
|
def handle_request(device_id, csr_pem, meta):
|
||||||
store.add_pending(device_id, csr_pem, meta)
|
store.add_pending(device_id, csr_pem, meta)
|
||||||
|
|
||||||
|
|
||||||
def finalize_issuance(device_id: str, csr_pem: str, state=None):
|
def finalize_issuance(device_id: str, csr_pem: str, common_name: str, state=None):
|
||||||
"""Sign a CSR, record it, and deliver it. Shared by manual approval
|
"""Sign a CSR, record it, and deliver it. Shared by manual approval
|
||||||
and the auto-renewal fast path so both stay in sync."""
|
and the auto-renewal fast path so both stay in sync. `common_name`
|
||||||
|
is resolved by the caller -- see resolve_common_name for fresh
|
||||||
|
issuance, and handle_renew's own logic for renewals (which must NOT
|
||||||
|
use CSR-based resolution -- it always keeps the existing CN)."""
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
|
|
||||||
cert_pem = ca.sign_csr(csr_pem, device_id, int(options["cert_validity_days"]))
|
cert_pem = ca.sign_csr(csr_pem, common_name, int(options["cert_validity_days"]))
|
||||||
leaf = x509.load_pem_x509_certificate(cert_pem.encode())
|
leaf = x509.load_pem_x509_certificate(cert_pem.encode())
|
||||||
not_after = leaf.not_valid_after_utc.isoformat()
|
not_after = leaf.not_valid_after_utc.isoformat()
|
||||||
store.mark_issued(device_id, cert_pem, not_after, leaf.serial_number, state=state)
|
store.mark_issued(device_id, cert_pem, not_after, leaf.serial_number, state=state)
|
||||||
@@ -155,14 +189,49 @@ def finalize_issuance(device_id: str, csr_pem: str, state=None):
|
|||||||
return cert_pem, not_after
|
return cert_pem, not_after
|
||||||
|
|
||||||
|
|
||||||
def handle_renew(device_id, csr_pem, timestamp, signature_b64, meta):
|
def handle_renew_begin(device_id):
|
||||||
"""Auto-issue a renewed cert IF, and only if, the requester proves
|
"""Step 1 of renewal: a node asks for a challenge.
|
||||||
possession of the *currently on-record* cert's private key, that
|
|
||||||
cert isn't revoked, and we're actually within the renewal window.
|
Only devices that already hold an issued, non-revoked cert get one, so
|
||||||
|
strangers can't make the server accumulate nonces. A device that gets no
|
||||||
|
answer should fall back to an ordinary enrollment request."""
|
||||||
|
if device_id in store.list_revoked():
|
||||||
|
log.info("renewal challenge refused for %s: device is revoked", device_id)
|
||||||
|
return
|
||||||
|
if device_id not in store.list_issued():
|
||||||
|
log.info(
|
||||||
|
"renewal challenge refused for %s: no issued cert on record "
|
||||||
|
"(it needs a normal enrollment request)", device_id,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
nonce, expires_in = challenge_store.issue(device_id)
|
||||||
|
mqtt_worker.publish_challenge(device_id, nonce, expires_in)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_renew(device_id, csr_pem, nonce, signature_b64, meta):
|
||||||
|
"""Step 2 of renewal. Auto-issue a renewed cert IF, and only if, the
|
||||||
|
requester proves possession of the *currently on-record* cert's private
|
||||||
|
key by signing the server's challenge, that cert isn't revoked, and
|
||||||
|
we're actually within the renewal window.
|
||||||
|
|
||||||
|
The signature must cover renew-v1|device_id|nonce|sha256(DER(csr)), so
|
||||||
|
it is bound to this device, to a nonce this server issued (single-use,
|
||||||
|
short-lived), and to the exact CSR being certified. A captured request
|
||||||
|
can't be replayed (the nonce is spent) and can't be re-targeted at a
|
||||||
|
different key (the CSR digest wouldn't match).
|
||||||
|
|
||||||
Any failure falls back to the ordinary manual-approval queue —
|
Any failure falls back to the ordinary manual-approval queue —
|
||||||
exactly as if this were a first-time request — rather than being
|
exactly as if this were a first-time request — rather than being
|
||||||
silently dropped, so a legitimate device with e.g. clock skew still
|
silently dropped, so a legitimate device that e.g. lost its challenge
|
||||||
gets a cert eventually, just with human review."""
|
still gets a cert eventually, just with human review.
|
||||||
|
|
||||||
|
CN handling for renewal is intentionally NOT the same as fresh
|
||||||
|
issuance: the renewed cert always keeps whatever CN the device's
|
||||||
|
CURRENT on-record cert already has. A renewal CSR's own CN (or any
|
||||||
|
other claimed identity) is never consulted -- renewal is about
|
||||||
|
extending validity / rotating keys, not about redefining who a
|
||||||
|
device is. Changing identity requires a fresh, humanly-approved
|
||||||
|
enrollment, not a renewal."""
|
||||||
|
|
||||||
def fall_back_to_manual(why):
|
def fall_back_to_manual(why):
|
||||||
log.info("renewal from %s falling back to manual approval: %s", device_id, why)
|
log.info("renewal from %s falling back to manual approval: %s", device_id, why)
|
||||||
@@ -172,27 +241,24 @@ def handle_renew(device_id, csr_pem, timestamp, signature_b64, meta):
|
|||||||
fall_back_to_manual("device is revoked")
|
fall_back_to_manual("device is revoked")
|
||||||
return
|
return
|
||||||
|
|
||||||
issued = store.list_issued().get(device_id)
|
existing_issued = store.list_issued().get(device_id)
|
||||||
if not issued:
|
if not existing_issued:
|
||||||
fall_back_to_manual("no prior issued cert on record")
|
fall_back_to_manual("no prior issued cert on record")
|
||||||
return
|
return
|
||||||
|
|
||||||
now = time.time()
|
not_after = datetime.datetime.fromisoformat(existing_issued["not_after"])
|
||||||
try:
|
|
||||||
ts = float(timestamp)
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
fall_back_to_manual("timestamp not a number")
|
|
||||||
return
|
|
||||||
if abs(now - ts) > RENEWAL_TIMESTAMP_SKEW_SECONDS:
|
|
||||||
fall_back_to_manual("timestamp outside allowed skew window")
|
|
||||||
return
|
|
||||||
|
|
||||||
not_after = datetime.datetime.fromisoformat(issued["not_after"])
|
|
||||||
renewal_opens_at = not_after - datetime.timedelta(days=int(options["renewal_window_days"]))
|
renewal_opens_at = not_after - datetime.timedelta(days=int(options["renewal_window_days"]))
|
||||||
if datetime.datetime.now(datetime.timezone.utc) < renewal_opens_at:
|
if datetime.datetime.now(datetime.timezone.utc) < renewal_opens_at:
|
||||||
fall_back_to_manual(
|
fall_back_to_manual(f"too early to renew (opens {renewal_opens_at.isoformat()})")
|
||||||
f"too early to renew (opens {renewal_opens_at.isoformat()})"
|
return
|
||||||
)
|
|
||||||
|
if not nonce:
|
||||||
|
fall_back_to_manual("no challenge nonce supplied (old or malformed renewal request)")
|
||||||
|
return
|
||||||
|
# Cheap pre-check so we don't do signature work for a nonce that can't
|
||||||
|
# be valid. The atomic consume below is what actually enforces single use.
|
||||||
|
if not challenge_store.is_active(device_id, nonce):
|
||||||
|
fall_back_to_manual("no active challenge for this device, or the nonce is wrong, expired or already used")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -201,18 +267,39 @@ def handle_renew(device_id, csr_pem, timestamp, signature_b64, meta):
|
|||||||
fall_back_to_manual("signature not valid base64")
|
fall_back_to_manual("signature not valid base64")
|
||||||
return
|
return
|
||||||
|
|
||||||
message = f"{device_id}|{int(ts)}|renew".encode()
|
# Rebuilt here from the CSR we actually received -- never from any
|
||||||
if not ca.verify_renewal_proof(issued["cert"], message, signature):
|
# digest or field the node sent alongside it.
|
||||||
|
try:
|
||||||
|
digest = csr_digest(csr_pem)
|
||||||
|
except ValueError:
|
||||||
|
fall_back_to_manual("CSR could not be parsed")
|
||||||
|
return
|
||||||
|
|
||||||
|
message = renewal_message(device_id, nonce, digest)
|
||||||
|
if not ca.verify_renewal_proof(existing_issued["cert"], message, signature):
|
||||||
fall_back_to_manual("proof-of-possession signature did not verify")
|
fall_back_to_manual("proof-of-possession signature did not verify")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Last gate before issuing. Invalid requests above never burn the nonce,
|
||||||
|
# and two concurrent requests with the same nonce can't both get here.
|
||||||
|
if not challenge_store.consume(device_id, nonce):
|
||||||
|
fall_back_to_manual("challenge was already used or has just expired")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Past every check: keep the EXISTING cert's CN, full stop. Never
|
||||||
|
# derived from the new CSR for a renewal.
|
||||||
|
preserved_common_name = extract_cert_common_name(existing_issued["cert"]) or device_id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_, new_not_after = finalize_issuance(device_id, csr_pem)
|
_, new_not_after = finalize_issuance(device_id, csr_pem, preserved_common_name)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
fall_back_to_manual(f"CSR rejected: {exc}")
|
fall_back_to_manual(f"CSR rejected: {exc}")
|
||||||
return
|
return
|
||||||
|
|
||||||
log.info("auto-renewed cert for %s (proof verified), now valid until %s", device_id, new_not_after)
|
log.info(
|
||||||
|
"auto-renewed cert for %s (proof verified), CN kept as %r, now valid until %s",
|
||||||
|
device_id, preserved_common_name, new_not_after,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
mqtt_worker = MqttWorker(
|
mqtt_worker = MqttWorker(
|
||||||
@@ -223,6 +310,7 @@ mqtt_worker = MqttWorker(
|
|||||||
topic_prefix=options["request_topic_prefix"],
|
topic_prefix=options["request_topic_prefix"],
|
||||||
on_request=handle_request,
|
on_request=handle_request,
|
||||||
on_renew=handle_renew,
|
on_renew=handle_renew,
|
||||||
|
on_renew_begin=handle_renew_begin,
|
||||||
)
|
)
|
||||||
mqtt_worker.start()
|
mqtt_worker.start()
|
||||||
|
|
||||||
@@ -237,12 +325,25 @@ def index():
|
|||||||
|
|
||||||
@app.route("/api/pending")
|
@app.route("/api/pending")
|
||||||
def api_pending():
|
def api_pending():
|
||||||
return jsonify(store.list_pending())
|
pending = store.list_pending()
|
||||||
|
enriched = {}
|
||||||
|
for device_id, entry in pending.items():
|
||||||
|
enriched[device_id] = dict(entry)
|
||||||
|
# What CN WOULD be used if approved right now (from the CSR) --
|
||||||
|
# purely for display, not stored, since it's cheap to recompute
|
||||||
|
# and this way it's never stale.
|
||||||
|
enriched[device_id]["resolved_common_name"] = resolve_common_name(device_id, entry["csr"])
|
||||||
|
return jsonify(enriched)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/issued")
|
@app.route("/api/issued")
|
||||||
def api_issued():
|
def api_issued():
|
||||||
return jsonify(store.list_issued())
|
issued = store.list_issued()
|
||||||
|
enriched = {}
|
||||||
|
for device_id, entry in issued.items():
|
||||||
|
enriched[device_id] = dict(entry)
|
||||||
|
enriched[device_id]["common_name"] = extract_cert_common_name(entry["cert"])
|
||||||
|
return jsonify(enriched)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/approve/<device_id>", methods=["POST"])
|
@app.route("/api/approve/<device_id>", methods=["POST"])
|
||||||
@@ -251,12 +352,17 @@ def api_approve(device_id):
|
|||||||
if not pending:
|
if not pending:
|
||||||
return jsonify({"error": "no pending request for that device"}), 404
|
return jsonify({"error": "no pending request for that device"}), 404
|
||||||
|
|
||||||
|
common_name = resolve_common_name(device_id, pending["csr"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_, not_after = finalize_issuance(device_id, pending["csr"], state=state)
|
_, not_after = finalize_issuance(device_id, pending["csr"], common_name, state=state)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return jsonify({"error": str(exc)}), 400
|
return jsonify({"error": str(exc)}), 400
|
||||||
|
|
||||||
return jsonify({"status": "issued", "device_id": device_id, "not_after": not_after})
|
return jsonify({
|
||||||
|
"status": "issued", "device_id": device_id,
|
||||||
|
"common_name": common_name, "not_after": not_after,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/reject/<device_id>", methods=["POST"])
|
@app.route("/api/reject/<device_id>", methods=["POST"])
|
||||||
|
|||||||
@@ -3,16 +3,31 @@ MQTT side of the enrollment protocol.
|
|||||||
|
|
||||||
Topics (prefix is configurable, default "cert/enroll"):
|
Topics (prefix is configurable, default "cert/enroll"):
|
||||||
<prefix>/<device_id>/request node -> here {"csr": "<PEM>", "meta": {...}}
|
<prefix>/<device_id>/request node -> here {"csr": "<PEM>", "meta": {...}}
|
||||||
<prefix>/<device_id>/renew node -> here {"csr": "<PEM>", "timestamp": <int>, "signature": "<base64>", "meta": {...}}
|
<prefix>/<device_id>/renew-begin node -> here (payload ignored) asks for a renewal challenge
|
||||||
|
<prefix>/<device_id>/challenge here -> node {"nonce": "<hex>", "expires_in": <seconds>} (not retained)
|
||||||
|
<prefix>/<device_id>/renew node -> here {"csr": "<PEM>", "nonce": "<hex>", "signature": "<base64>", "meta": {...}}
|
||||||
<prefix>/<device_id>/issued here -> node {"cert": "<PEM>", "ca": "<PEM>"} (retained)
|
<prefix>/<device_id>/issued here -> node {"cert": "<PEM>", "ca": "<PEM>"} (retained)
|
||||||
<prefix>/<device_id>/rejected here -> node {"reason": "..."}
|
<prefix>/<device_id>/rejected here -> node {"reason": "..."}
|
||||||
<prefix>/<device_id>/revoked here -> node {"reason": "..."} (best-effort notice; see DEVICE_PROTOCOL.md)
|
<prefix>/<device_id>/revoked here -> node {"reason": "..."} (best-effort notice; see DEVICE_PROTOCOL.md)
|
||||||
|
|
||||||
|
Renewal needs no clock on the node. The node asks for a challenge, gets a
|
||||||
|
single-use nonce back, and signs "renew-v1|<device_id>|<nonce>|<sha256 of
|
||||||
|
the CSR's DER>" with its CURRENT key. See challenges.py and
|
||||||
|
RENEWAL_PROTOCOL.md.
|
||||||
|
|
||||||
|
device_id is expected to be unique per physical device (not a shared
|
||||||
|
bootstrap identity) -- that's what makes per-device topics work without
|
||||||
|
any extra filtering in the payload. The cert's CN is a separate concern,
|
||||||
|
set from the CSR by main.py/ca.py, and may deliberately be shared across
|
||||||
|
many devices (e.g. one CN per device category) -- that has no bearing on
|
||||||
|
topic routing here.
|
||||||
|
|
||||||
See DEVICE_PROTOCOL.md for the full spec devices should implement.
|
See DEVICE_PROTOCOL.md for the full spec devices should implement.
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
@@ -22,31 +37,79 @@ log = logging.getLogger("mqtt_worker")
|
|||||||
|
|
||||||
|
|
||||||
class MqttWorker:
|
class MqttWorker:
|
||||||
def __init__(self, host, port, username, password, topic_prefix, on_request, on_renew):
|
def __init__(self, host, port, username, password, topic_prefix, on_request, on_renew, on_renew_begin):
|
||||||
self.topic_prefix = topic_prefix.rstrip("/")
|
self.topic_prefix = topic_prefix.rstrip("/")
|
||||||
self.on_request = on_request # callback(device_id, csr_pem, meta)
|
self.on_request = on_request # callback(device_id, csr_pem, meta)
|
||||||
self.on_renew = on_renew # callback(device_id, csr_pem, timestamp, signature_b64, meta)
|
self.on_renew_begin = on_renew_begin # callback(device_id)
|
||||||
|
self.on_renew = on_renew # callback(device_id, csr_pem, nonce, signature_b64, meta)
|
||||||
|
|
||||||
self.client = mqtt.Client(client_id="mqtt-cert-manager")
|
self.client = mqtt.Client(client_id="mqtt-cert-manager")
|
||||||
if username:
|
if username:
|
||||||
self.client.username_pw_set(username, password or None)
|
self.client.username_pw_set(username, password or None)
|
||||||
self.client.on_connect = self._on_connect
|
self.client.on_connect = self._on_connect
|
||||||
|
self.client.on_disconnect = self._on_disconnect
|
||||||
self.client.on_message = self._on_message
|
self.client.on_message = self._on_message
|
||||||
|
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.client.connect(self.host, self.port, keepalive=60)
|
# Returns immediately: the connect (and its retries) happen in the
|
||||||
thread = threading.Thread(target=self.client.loop_forever, daemon=True)
|
# background, so a broker that isn't reachable YET -- e.g. Home
|
||||||
|
# Assistant just booted and Mosquitto hasn't started -- doesn't
|
||||||
|
# crash the whole add-on or block the web UI from coming up.
|
||||||
|
thread = threading.Thread(target=self._run, daemon=True, name="mqtt-worker")
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
def _run(self):
|
||||||
|
self.client.reconnect_delay_set(min_delay=1, max_delay=30)
|
||||||
|
delay = 1
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
# This is the plain TCP connect. MQTT itself (CONNECT /
|
||||||
|
# CONNACK, auth) only starts once this succeeds.
|
||||||
|
self.client.connect(self.host, self.port, keepalive=60)
|
||||||
|
except OSError as exc:
|
||||||
|
# ConnectionRefusedError (nothing listening), gaierror
|
||||||
|
# (hostname doesn't resolve), timeouts, etc. all land here.
|
||||||
|
log.warning(
|
||||||
|
"cannot reach MQTT broker at %s:%s (%s: %s) - retrying in %ss. "
|
||||||
|
"Check the mqtt_host / mqtt_port options, and that Mosquitto is running.",
|
||||||
|
self.host, self.port, type(exc).__name__, exc, delay,
|
||||||
|
)
|
||||||
|
time.sleep(delay)
|
||||||
|
delay = min(delay * 2, 30)
|
||||||
|
continue
|
||||||
|
# Connected at the TCP level. From here paho handles drops and
|
||||||
|
# reconnects itself (using reconnect_delay_set above); this only
|
||||||
|
# returns if disconnect() is ever called explicitly.
|
||||||
|
self.client.loop_forever()
|
||||||
|
return
|
||||||
|
|
||||||
def _on_connect(self, client, userdata, flags, rc):
|
def _on_connect(self, client, userdata, flags, rc):
|
||||||
|
if rc != 0:
|
||||||
|
# The TCP connection worked but the BROKER said no -- a different
|
||||||
|
# failure from "connection refused". Usually bad credentials.
|
||||||
|
log.error(
|
||||||
|
"MQTT broker rejected the connection: %s "
|
||||||
|
"(check the mqtt_username / mqtt_password options)",
|
||||||
|
mqtt.connack_string(rc),
|
||||||
|
)
|
||||||
|
return
|
||||||
request_topic = f"{self.topic_prefix}/+/request"
|
request_topic = f"{self.topic_prefix}/+/request"
|
||||||
|
renew_begin_topic = f"{self.topic_prefix}/+/renew-begin"
|
||||||
renew_topic = f"{self.topic_prefix}/+/renew"
|
renew_topic = f"{self.topic_prefix}/+/renew"
|
||||||
client.subscribe(request_topic, qos=1)
|
client.subscribe(request_topic, qos=1)
|
||||||
|
client.subscribe(renew_begin_topic, qos=1)
|
||||||
client.subscribe(renew_topic, qos=1)
|
client.subscribe(renew_topic, qos=1)
|
||||||
log.info("connected to broker, subscribed to %s and %s", request_topic, renew_topic)
|
log.info(
|
||||||
|
"connected to broker, subscribed to %s, %s and %s",
|
||||||
|
request_topic, renew_begin_topic, renew_topic,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _on_disconnect(self, client, userdata, rc):
|
||||||
|
if rc != 0:
|
||||||
|
log.warning("lost connection to MQTT broker (rc=%s); retrying automatically", rc)
|
||||||
|
|
||||||
def _on_message(self, client, userdata, msg):
|
def _on_message(self, client, userdata, msg):
|
||||||
parts = msg.topic.split("/")
|
parts = msg.topic.split("/")
|
||||||
@@ -54,11 +117,21 @@ class MqttWorker:
|
|||||||
return
|
return
|
||||||
device_id, kind = parts[-2], parts[-1]
|
device_id, kind = parts[-2], parts[-1]
|
||||||
|
|
||||||
|
if kind == "renew-begin":
|
||||||
|
# Nothing in this payload is used, so don't insist on valid JSON
|
||||||
|
# (a node may well send an empty message).
|
||||||
|
log.info("renewal challenge requested by %s", device_id)
|
||||||
|
self.on_renew_begin(device_id)
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
payload = json.loads(msg.payload.decode())
|
payload = json.loads(msg.payload.decode())
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
log.warning("malformed payload from %s on %s: %s", device_id, msg.topic, exc)
|
log.warning("malformed payload from %s on %s: %s", device_id, msg.topic, exc)
|
||||||
return
|
return
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
log.warning("malformed payload from %s on %s: expected a JSON object", device_id, msg.topic)
|
||||||
|
return
|
||||||
|
|
||||||
if kind == "request":
|
if kind == "request":
|
||||||
try:
|
try:
|
||||||
@@ -72,13 +145,29 @@ class MqttWorker:
|
|||||||
elif kind == "renew":
|
elif kind == "renew":
|
||||||
try:
|
try:
|
||||||
csr_pem = payload["csr"]
|
csr_pem = payload["csr"]
|
||||||
timestamp = payload["timestamp"]
|
|
||||||
signature_b64 = payload["signature"]
|
signature_b64 = payload["signature"]
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
log.warning("malformed renewal from %s: missing %s", device_id, exc)
|
log.warning("malformed renewal from %s: missing %s", device_id, exc)
|
||||||
return
|
return
|
||||||
|
if not isinstance(csr_pem, str):
|
||||||
|
log.warning("malformed renewal from %s: csr must be a string", device_id)
|
||||||
|
return
|
||||||
|
nonce = payload.get("nonce")
|
||||||
|
if nonce is None and "timestamp" in payload:
|
||||||
|
log.warning(
|
||||||
|
"renewal from %s uses the old timestamp format, which is no longer "
|
||||||
|
"supported; it will go to manual approval", device_id,
|
||||||
|
)
|
||||||
log.info("renewal request received from %s", device_id)
|
log.info("renewal request received from %s", device_id)
|
||||||
self.on_renew(device_id, csr_pem, timestamp, signature_b64, payload.get("meta", {}))
|
self.on_renew(device_id, csr_pem, nonce, signature_b64, payload.get("meta", {}))
|
||||||
|
|
||||||
|
def publish_challenge(self, device_id: str, nonce: str, expires_in: int):
|
||||||
|
# Deliberately NOT retained: a retained challenge would be handed to
|
||||||
|
# any later subscriber long after it expired.
|
||||||
|
topic = f"{self.topic_prefix}/{device_id}/challenge"
|
||||||
|
payload = json.dumps({"nonce": nonce, "expires_in": expires_in})
|
||||||
|
self.client.publish(topic, payload, qos=1, retain=False)
|
||||||
|
log.info("published renewal challenge for %s (valid %ss)", device_id, expires_in)
|
||||||
|
|
||||||
def publish_issued(self, device_id: str, cert_pem: str, ca_pem: str):
|
def publish_issued(self, device_id: str, cert_pem: str, ca_pem: str):
|
||||||
topic = f"{self.topic_prefix}/{device_id}/issued"
|
topic = f"{self.topic_prefix}/{device_id}/issued"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ async function refreshPending() {
|
|||||||
const meta = Object.entries(entry.meta || {}).map(([k, v]) => `${k}: ${v}`).join(", ");
|
const meta = Object.entries(entry.meta || {}).map(([k, v]) => `${k}: ${v}`).join(", ");
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td>${deviceId}</td>
|
<td>${deviceId}</td>
|
||||||
|
<td>${entry.resolved_common_name}</td>
|
||||||
<td>${requested}</td>
|
<td>${requested}</td>
|
||||||
<td>${meta || "-"}</td>
|
<td>${meta || "-"}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -50,7 +51,7 @@ async function refreshIssued() {
|
|||||||
const action = isRevoked
|
const action = isRevoked
|
||||||
? `<span class="empty">revoked</span>`
|
? `<span class="empty">revoked</span>`
|
||||||
: `<button class="revoke" data-id="${deviceId}">Revoke</button>`;
|
: `<button class="revoke" data-id="${deviceId}">Revoke</button>`;
|
||||||
row.innerHTML = `<td>${deviceId}</td><td>${issued}</td><td>${expires}</td><td>${action}</td>`;
|
row.innerHTML = `<td>${deviceId}</td><td>${entry.common_name}</td><td>${issued}</td><td>${expires}</td><td>${action}</td>`;
|
||||||
tbody.appendChild(row);
|
tbody.appendChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
"""Simple JSON-file store for pending requests and issued cert records.
|
"""Simple JSON-file store for pending requests and issued cert records.
|
||||||
|
|
||||||
|
Keyed by device_id -- the unique per-device identifier from the MQTT
|
||||||
|
topic path (cert/enroll/<device_id>/...). CN is deliberately NOT unique
|
||||||
|
in this deployment (many devices share one CN per category, for ACL
|
||||||
|
grouping), so it can't be used as a storage key -- device_id is the
|
||||||
|
only thing guaranteed unique per physical device.
|
||||||
|
|
||||||
A real deployment could swap this for sqlite, but request volume here is
|
A real deployment could swap this for sqlite, but request volume here is
|
||||||
tiny (one entry per physical device) so a flat file is fine and easy to
|
tiny (one entry per physical device) so a flat file is fine and easy to
|
||||||
inspect/back up.
|
inspect/back up.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<h2>Pending requests</h2>
|
<h2>Pending requests</h2>
|
||||||
<table id="pending-table">
|
<table id="pending-table">
|
||||||
<thead><tr><th>Device</th><th>Requested</th><th>Info</th><th></th></tr></thead>
|
<thead><tr><th>Device</th><th>CN</th><th>Requested</th><th>Info</th><th></th></tr></thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
<p id="pending-empty" class="empty" style="display:none">No pending requests. Nodes that ask for a certificate will show up here.</p>
|
<p id="pending-empty" class="empty" style="display:none">No pending requests. Nodes that ask for a certificate will show up here.</p>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<h2>Issued certificates</h2>
|
<h2>Issued certificates</h2>
|
||||||
<table id="issued-table">
|
<table id="issued-table">
|
||||||
<thead><tr><th>Device</th><th>Issued</th><th>Expires</th><th></th></tr></thead>
|
<thead><tr><th>Device</th><th>CN</th><th>Issued</th><th>Expires</th><th></th></tr></thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
<p id="issued-empty" class="empty" style="display:none">No certificates issued yet.</p>
|
<p id="issued-empty" class="empty" style="display:none">No certificates issued yet.</p>
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
# As of Supervisor 2026.04+, HA no longer injects BUILD_FROM automatically,
|
|
||||||
# so we pin it explicitly here. If your Supervisor is older/newer and this
|
|
||||||
# fails to build, check https://github.com/home-assistant/docker-base for the
|
|
||||||
# current recommended base image tag and update the line below.
|
|
||||||
build_from:
|
|
||||||
amd64: "ghcr.io/home-assistant/base:latest"
|
|
||||||
aarch64: "ghcr.io/home-assistant/base:latest"
|
|
||||||
armv7: "ghcr.io/home-assistant/base:latest"
|
|
||||||
armhf: "ghcr.io/home-assistant/base:latest"
|
|
||||||
i386: "ghcr.io/home-assistant/base:latest"
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
name: "MQTT Certificate Manager"
|
name: "MQTT Certificate Manager"
|
||||||
version: "0.3.3"
|
version: "0.6.0"
|
||||||
slug: "mqtt_cert_manager"
|
slug: "mqtt_cert_manager"
|
||||||
description: "Local CA that issues and manages TLS client certificates for MQTT nodes"
|
description: "Local CA that issues and manages TLS client certificates for MQTT nodes"
|
||||||
url: "https://gitea.viratak.com/eta/mqtt-cert-manager"
|
url: "https://gitea.viratak.com/bitopa/virarepo/src/branch/main/mqtt-cert-manager"
|
||||||
# Points Supervisor at a pre-built image instead of building locally on
|
# Points Supervisor at a pre-built image instead of building locally on
|
||||||
# install. {arch} is substituted with each entry in "arch:" below (amd64,
|
# install. {arch} is substituted with each entry in "arch:" below (amd64,
|
||||||
# aarch64, ...) — Supervisor then pulls
|
# aarch64, ...) — Supervisor then pulls
|
||||||
@@ -10,7 +10,7 @@ url: "https://gitea.viratak.com/eta/mqtt-cert-manager"
|
|||||||
# REPLACE git.example.com/YOUR_USER with your actual Gitea host + owner.
|
# REPLACE git.example.com/YOUR_USER with your actual Gitea host + owner.
|
||||||
# Remove this line entirely to fall back to local building (e.g. while
|
# Remove this line entirely to fall back to local building (e.g. while
|
||||||
# developing, before you've set up CI).
|
# developing, before you've set up CI).
|
||||||
image: "gitea.viratak.com/eta/mqtt-cert-manager-{arch}"
|
image: "gitea.viratak.com/bitopa/mqtt-cert-manager-{arch}"
|
||||||
# TEMPORARY: restricted to amd64 only while developing against a single
|
# TEMPORARY: restricted to amd64 only while developing against a single
|
||||||
# Dell thin client. Restore the full list before publishing for others —
|
# Dell thin client. Restore the full list before publishing for others —
|
||||||
# see the commented-out entries below.
|
# see the commented-out entries below.
|
||||||
@@ -42,8 +42,10 @@ options:
|
|||||||
mqtt_password: ""
|
mqtt_password: ""
|
||||||
request_topic_prefix: "cert/enroll"
|
request_topic_prefix: "cert/enroll"
|
||||||
cert_validity_days: 825
|
cert_validity_days: 825
|
||||||
broker_hostnames: "core-mosquitto,localhost"
|
broker_hostnames: "homeassistant.local,192.168.1.80,core-mosquitto,localhost"
|
||||||
renewal_window_days: 30
|
renewal_window_days: 30
|
||||||
|
cert_organization: "Viratak Telecommunications"
|
||||||
|
cert_organizational_unit: "Cloudihome"
|
||||||
|
|
||||||
schema:
|
schema:
|
||||||
mqtt_host: str
|
mqtt_host: str
|
||||||
@@ -54,3 +56,5 @@ schema:
|
|||||||
cert_validity_days: int(30,3650)
|
cert_validity_days: int(30,3650)
|
||||||
broker_hostnames: str
|
broker_hostnames: str
|
||||||
renewal_window_days: int(1,365)
|
renewal_window_days: int(1,365)
|
||||||
|
cert_organization: str?
|
||||||
|
cert_organizational_unit: str?
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# https://developers.home-assistant.io/docs/apps/repository#repository-configuration
|
# https://developers.home-assistant.io/docs/apps/repository#repository-configuration
|
||||||
name: Viratak Home Assistant app repository
|
name: Viratak Home Assistant app repository
|
||||||
url: 'https://gitea.viratak.com/eta/virarepo'
|
url: 'https://gitea.viratak.com/bitopa/virarepo'
|
||||||
maintainer: Saman Sajedi <sajedi@viratak.com>
|
maintainer: Saman Sajedi <sajedi@viratak.com>
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.8
|
||||||
|
|
||||||
|
- Fixed TLS access control bug
|
||||||
|
|
||||||
|
## 0.5.5
|
||||||
|
|
||||||
|
- Fixed logging issue
|
||||||
|
|
||||||
|
## 0.5.4
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.5.1 - 2026-10-11
|
||||||
|
|
||||||
|
- Minor bug fixed
|
||||||
|
|
||||||
|
## 0.5.0 - 2026-10-11
|
||||||
|
|
||||||
|
- Added pre-built docker image
|
||||||
|
- Fixed some translation issues
|
||||||
|
|
||||||
|
## 0.4.1 - 2026-10-11
|
||||||
|
|
||||||
|
- Fixed Translation indentation issue
|
||||||
|
|
||||||
|
## 0.4.0
|
||||||
|
|
||||||
|
- Added descriptions in configuration
|
||||||
|
- Added Persian support in configuration
|
||||||
|
|
||||||
|
## 0.3.3
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.3.2
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.3.1
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.3.0
|
||||||
|
|
||||||
|
- Added separated ACL's
|
||||||
|
- Improved logging capabilities
|
||||||
|
|
||||||
|
## 0.2.5
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.2.4
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.2.3
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.2.2
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
- Fixed app icon
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
- Added app icon
|
||||||
|
- Improved app configuration
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
- Initializing the Application
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
FROM eclipse-mosquitto:2
|
||||||
|
|
||||||
|
# Install jq (needed by run.sh for config parsing)
|
||||||
|
RUN apk add --no-cache jq
|
||||||
|
|
||||||
|
# Copy and prepare the entrypoint
|
||||||
|
COPY run.sh /run.sh
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
|
# Optional but recommended labels
|
||||||
|
LABEL \
|
||||||
|
io.hass.name="Visquitto" \
|
||||||
|
io.hass.description="Second private Mosquitto broker for bitopa nodes" \
|
||||||
|
io.hass.type="addon" \
|
||||||
|
io.hass.arch="amd64"
|
||||||
|
|
||||||
|
CMD [ "/run.sh" ]
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Visquitto
|
||||||
|
|
||||||
|
Visquitto is a simple Mosquitto broker setup intended to run on a separate port and be used alongside [mqtt-cert-manager](https://gitea.viratak.com/bitopa/virarepo/src/branch/main/mqtt-cert-manager) and custom MQTT nodes.
|
||||||
|
|
||||||
|
This is not a full certificate-management platform or a Home Assistant-only app. It is a lightweight broker instance for local MQTT traffic, designed to coexist with [mqtt-cert-manager](https://gitea.viratak.com/bitopa/virarepo/src/branch/main/mqtt-cert-manager) and custom client code.
|
||||||
|
|
||||||
|
## What it is
|
||||||
|
|
||||||
|
- A standard Mosquitto broker
|
||||||
|
- Configured for a dedicated port, separate from the default broker
|
||||||
|
- Meant to be used alongside [mqtt-cert-manager](https://gitea.viratak.com/bitopa/virarepo/src/branch/main/mqtt-cert-manager) and custom MQTT nodes
|
||||||
|
- Intended for local/private network use
|
||||||
|
|
||||||
|
## Why use it
|
||||||
|
|
||||||
|
If you want a second MQTT broker for a specific project, workflow, or device group, Visquitto gives you:
|
||||||
|
|
||||||
|
- a clean, separate broker port
|
||||||
|
- a simple local MQTT endpoint for custom nodes and devices
|
||||||
|
- isolation from your main broker traffic
|
||||||
|
- an easy way to pair it with your own app logic
|
||||||
|
|
||||||
|
## Typical setup
|
||||||
|
|
||||||
|
Visquitto is designed to be used like this:
|
||||||
|
|
||||||
|
- Your main app runs normally
|
||||||
|
- Custom nodes or devices connect to the Visquitto broker
|
||||||
|
- The broker listens on its own port instead of the default Mosquitto port
|
||||||
|
- Traffic is kept separate from the primary broker environment
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- A machine/container/environment capable of running Mosquitto
|
||||||
|
- A separate port for the broker
|
||||||
|
- Your own app and custom MQTT clients/nodes
|
||||||
|
- Local or private network access as needed
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Common settings include:
|
||||||
|
|
||||||
|
- broker port
|
||||||
|
- listener configuration
|
||||||
|
- allow/deny rules if needed
|
||||||
|
- persistence settings
|
||||||
|
- logging options
|
||||||
|
- TLS settings if you choose to enable them
|
||||||
|
|
||||||
|
This project is intentionally minimal: it provides a broker for your other app and custom nodes rather than trying to manage a larger certificate or onboarding system.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- This is a plain Mosquitto-based broker setup
|
||||||
|
- It is meant to complement another app, not replace it
|
||||||
|
- It is best suited for local experiments, custom node integrations, and paired app workflows
|
||||||
|
- If you are using TLS or custom auth, configure it explicitly for your environment
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Please check the repository license file for usage terms if one is included in the project.
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
name: Visquitto
|
||||||
|
version: "0.6.0"
|
||||||
|
slug: visquitto
|
||||||
|
description: Second private Mosquitto broker for bitopa nodes
|
||||||
|
url: "https://gitea.viratak.com/bitopa/virarepo/src/branch/main/visquitto"
|
||||||
|
image: "gitea.viratak.com/bitopa/visquitto-{arch}"
|
||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
init: false
|
||||||
|
startup: services
|
||||||
|
boot: auto
|
||||||
|
ports:
|
||||||
|
1883/tcp: 1993
|
||||||
|
8883/tcp: 9993
|
||||||
|
ports_description:
|
||||||
|
1883/tcp: MQTT (plain)
|
||||||
|
8883/tcp: MQTT over TLS
|
||||||
|
map:
|
||||||
|
- addon_config:rw
|
||||||
|
- share:rw
|
||||||
|
- ssl:ro
|
||||||
|
options:
|
||||||
|
users: []
|
||||||
|
log_dest: []
|
||||||
|
log_type: []
|
||||||
|
require_certificate: false
|
||||||
|
cafile: mqtt-cert-manager-ca.crt
|
||||||
|
certfile: mosquitto-server.crt
|
||||||
|
keyfile: mosquitto-server.key
|
||||||
|
schema:
|
||||||
|
users:
|
||||||
|
- username: str
|
||||||
|
password: password
|
||||||
|
log_dest:
|
||||||
|
- list(none|stdout|stderr|topic)?
|
||||||
|
log_type:
|
||||||
|
- list(none|debug|error|warning|notice|information|subscribe|unsubscribe|websockets|all)?
|
||||||
|
require_certificate: bool
|
||||||
|
cafile: str
|
||||||
|
certfile: str
|
||||||
|
keyfile: str
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,162 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
CONFIG=/config
|
||||||
|
SHARE=/share/visquitto
|
||||||
|
DATA=/data/mosquitto
|
||||||
|
PASSWD=/data/passwd
|
||||||
|
CERTDIR=/data/certs
|
||||||
|
|
||||||
|
mkdir -p "$SHARE" "$DATA" "$CERTDIR"
|
||||||
|
chown -R mosquitto:mosquitto "$DATA"
|
||||||
|
|
||||||
|
CAFILE=$(jq -r '.cafile' /data/options.json)
|
||||||
|
CERTFILE=$(jq -r '.certfile' /data/options.json)
|
||||||
|
KEYFILE=$(jq -r '.keyfile' /data/options.json)
|
||||||
|
|
||||||
|
# ---- Check plugins exist ----
|
||||||
|
for p in /usr/lib/mosquitto_acl_file.so /usr/lib/mosquitto_password_file.so; do
|
||||||
|
[ -f "$p" ] || { echo "Missing plugin $p" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---- Certificates: copied at every start, readable by mosquitto ----
|
||||||
|
for f in "$CAFILE" "$CERTFILE" "$KEYFILE"; do
|
||||||
|
[ -f "/ssl/$f" ] || { echo "Missing /ssl/$f" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
|
cp "/ssl/$CAFILE" "$CERTDIR/ca.pem"
|
||||||
|
cp "/ssl/$CERTFILE" "$CERTDIR/cert.pem"
|
||||||
|
cp "/ssl/$KEYFILE" "$CERTDIR/key.pem"
|
||||||
|
chown -R mosquitto:mosquitto "$CERTDIR"
|
||||||
|
chmod 644 "$CERTDIR/ca.pem" "$CERTDIR/cert.pem"
|
||||||
|
chmod 600 "$CERTDIR/key.pem"
|
||||||
|
|
||||||
|
# ---- Defaults in /config (regenerated at every start) ----
|
||||||
|
cat > "$CONFIG/mosquitto.conf" <<EOF
|
||||||
|
$(jq -r '.log_dest[]? | "log_dest \(.)"' /data/options.json)
|
||||||
|
$(jq -r '.log_type[]? | "log_type \(.)"' /data/options.json)
|
||||||
|
log_timestamp_format %Y-%m-%d %H:%M:%S
|
||||||
|
|
||||||
|
persistence true
|
||||||
|
persistence_location $DATA/
|
||||||
|
max_queued_messages 8192
|
||||||
|
|
||||||
|
plugin_load passwd /usr/lib/mosquitto_password_file.so
|
||||||
|
plugin_opt_password_file $PASSWD
|
||||||
|
|
||||||
|
plugin_load acl_plain /usr/lib/mosquitto_acl_file.so
|
||||||
|
plugin_opt_acl_file $DATA/acl_plain
|
||||||
|
|
||||||
|
plugin_load acl_tls /usr/lib/mosquitto_acl_file.so
|
||||||
|
plugin_opt_acl_file $DATA/acl_tls
|
||||||
|
|
||||||
|
include_dir $SHARE
|
||||||
|
|
||||||
|
# Plain listener (host port 1993): password users only
|
||||||
|
listener 1883
|
||||||
|
protocol mqtt
|
||||||
|
allow_anonymous false
|
||||||
|
plugin_use passwd
|
||||||
|
plugin_use acl_plain
|
||||||
|
|
||||||
|
# TLS listener (host port 9993): client certificate required
|
||||||
|
listener 8883
|
||||||
|
protocol mqtt
|
||||||
|
allow_anonymous false
|
||||||
|
cafile $CERTDIR/ca.pem
|
||||||
|
certfile $CERTDIR/cert.pem
|
||||||
|
keyfile $CERTDIR/key.pem
|
||||||
|
tls_version tlsv1.2
|
||||||
|
require_certificate true
|
||||||
|
use_identity_as_username true
|
||||||
|
plugin_use passwd
|
||||||
|
plugin_use acl_tls
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# plain ACL
|
||||||
|
cat > "$CONFIG/acl_plain" <<EOF
|
||||||
|
# ============================================================
|
||||||
|
# Not certified devices
|
||||||
|
# ============================================================
|
||||||
|
user hamqtt
|
||||||
|
|
||||||
|
# Test topic
|
||||||
|
topic readwrite test
|
||||||
|
# Initial enrollment
|
||||||
|
topic write cert/enroll/+/request
|
||||||
|
topic read cert/enroll/+/issued
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Certificate manager
|
||||||
|
# ============================================================
|
||||||
|
user viracert
|
||||||
|
|
||||||
|
topic read cert/enroll/+/request
|
||||||
|
topic write cert/enroll/+/issued
|
||||||
|
topic read cert/enroll/+/renew
|
||||||
|
topic read cert/enroll/+/renew-begin
|
||||||
|
topic write cert/enroll/+/challenge
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# TLS ACL
|
||||||
|
cat > "$CONFIG/acl_tls" <<EOF
|
||||||
|
# Default rule for every certificate client. %u is the certificate CN.
|
||||||
|
pattern readwrite clients/%u/#
|
||||||
|
pattern write cert/enroll/%u/renew
|
||||||
|
pattern write cert/enroll/%u/renew-begin
|
||||||
|
pattern read cert/enroll/%u/challenge
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ---- User customization in /share (created once, never overwritten) ----
|
||||||
|
if grep -qE '^\s*(listener|port|bind_address)\b' "$SHARE/mosquitto.conf"; then
|
||||||
|
echo "ERROR: $SHARE/mosquitto.conf must not define listeners (listener/port/bind_address)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
||||||
|
echo "# Extra global Mosquitto options (loaded with include_dir, before the listeners)" > "$SHARE/mosquitto.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$SHARE/acl_plain" ]; then
|
||||||
|
cat > "$SHARE/acl_plain" <<EOF
|
||||||
|
# Extra ACL rules for the plain listener, appended to the default, for example:
|
||||||
|
# user enroll
|
||||||
|
# topic write certs/request/#
|
||||||
|
# topic read certs/response/#
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$SHARE/acl_tls" ]; then
|
||||||
|
cat > "$SHARE/acl_tls" <<EOF
|
||||||
|
# Extra ACL rules for the TLS listener (user = certificate CN), appended to the default, for example:
|
||||||
|
# user hamt
|
||||||
|
# topic read broadcast/#
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 644 "$SHARE/mosquitto.conf"
|
||||||
|
chmod 600 "$SHARE/acl_plain" "$SHARE/acl_tls"
|
||||||
|
|
||||||
|
# ---- Merge defaults + user ACLs into the files Mosquitto reads ----
|
||||||
|
{ cat "$CONFIG/acl_plain"; echo; cat "$SHARE/acl_plain"; echo; } > "$DATA/acl_plain"
|
||||||
|
{ cat "$CONFIG/acl_tls"; echo; cat "$SHARE/acl_tls"; echo; } > "$DATA/acl_tls"
|
||||||
|
|
||||||
|
for f in "$DATA/acl_plain" "$DATA/acl_tls"; do
|
||||||
|
chown mosquitto:mosquitto "$f"
|
||||||
|
chmod 600 "$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---- Users from the panel ----
|
||||||
|
rm -f "$PASSWD"
|
||||||
|
touch "$PASSWD"
|
||||||
|
jq -r '.users[] | [.username, .password] | @tsv' /data/options.json |
|
||||||
|
while IFS="$(printf '\t')" read -r user pass; do
|
||||||
|
mosquitto_passwd -b "$PASSWD" "$user" "$pass"
|
||||||
|
done
|
||||||
|
chown mosquitto:mosquitto "$PASSWD"
|
||||||
|
chmod 0700 "$PASSWD"
|
||||||
|
|
||||||
|
[ -s "$PASSWD" ] || echo "Warning: no users defined, nobody can log in on the plain listener" >&2
|
||||||
|
|
||||||
|
exec mosquitto -c "$CONFIG/mosquitto.conf"
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
configuration:
|
||||||
|
users:
|
||||||
|
name: Users
|
||||||
|
description: List of MQTT users (username + password)
|
||||||
|
fields:
|
||||||
|
username:
|
||||||
|
name: Username
|
||||||
|
description: MQTT username
|
||||||
|
password:
|
||||||
|
name: Password
|
||||||
|
description: MQTT password
|
||||||
|
log_dest:
|
||||||
|
name: Log destinations
|
||||||
|
description: Where Mosquitto should send log messages (none, stdout, stderr, topic)
|
||||||
|
log_type:
|
||||||
|
name: Log types
|
||||||
|
description: Which log levels/events to enable (none, debug, error, warning, notice, information, subscribe, unsubscribe, websockets, all)
|
||||||
|
require_certificate:
|
||||||
|
name: Require client certificate
|
||||||
|
description: If enabled, clients must present a valid certificate signed by the CA
|
||||||
|
cafile:
|
||||||
|
name: CA certificate file
|
||||||
|
description: Filename of the CA certificate (relative to the ssl folder)
|
||||||
|
certfile:
|
||||||
|
name: Server certificate file
|
||||||
|
description: Filename of the Mosquitto server certificate (relative to the ssl folder)
|
||||||
|
keyfile:
|
||||||
|
name: Server private key file
|
||||||
|
description: Filename of the Mosquitto server private key (relative to the ssl folder)
|
||||||
|
|
||||||
|
network:
|
||||||
|
1883/tcp: MQTT (plain)
|
||||||
|
8883/tcp: MQTT over TLS
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
configuration:
|
||||||
|
users:
|
||||||
|
name: کاربران
|
||||||
|
description: لیست کاربران MQTT (نام کاربری + رمز عبور)
|
||||||
|
fields:
|
||||||
|
username:
|
||||||
|
name: نام کاربری
|
||||||
|
description: نام کاربری MQTT
|
||||||
|
password:
|
||||||
|
name: رمز عبور
|
||||||
|
description: رمز عبور MQTT
|
||||||
|
log_dest:
|
||||||
|
name: مقصدهای لاگ
|
||||||
|
description: محل ارسال پیامهای لاگ توسط برنامهی ماسکیتو (none، stdout، stderr، topic)
|
||||||
|
log_type:
|
||||||
|
name: انواع لاگ
|
||||||
|
description: سطوح و رویدادهای لاگ که باید فعال شوند (none، debug، error، warning، notice، information، subscribe، unsubscribe، websockets، all)
|
||||||
|
require_certificate:
|
||||||
|
name: نیاز به گواهی کلاینت
|
||||||
|
description: در صورت فعال بودن، کلاینتها باید گواهی معتبر امضا شده توسط CA ارائه دهند
|
||||||
|
cafile:
|
||||||
|
name: فایل گواهی CA
|
||||||
|
description: نام فایل گواهی CA (نسبت به پوشه ssl)
|
||||||
|
certfile:
|
||||||
|
name: فایل گواهی سرور
|
||||||
|
description: نام فایل گواهی سرور برنامهی ماسکیتو (نسبت به پوشه ssl)
|
||||||
|
keyfile:
|
||||||
|
name: فایل کلید خصوصی سرور
|
||||||
|
description: نام فایل کلید خصوصی سرور برنامهی ماسکیتو (نسبت به پوشه ssl)
|
||||||
|
|
||||||
|
network:
|
||||||
|
1883/tcp: پورت MQTT (ساده)
|
||||||
|
8883/tcp: پورت MQTT روی TLS
|
||||||
Reference in New Issue
Block a user