Compare commits

...

8 Commits

Author SHA1 Message Date
eta edb2a6df1d acl, log
build-and-push / check-branch (push) Successful in 15s
build-and-push / build (amd64, linux/amd64) (push) Successful in 11m46s
- separated ACL's for as plain and TLS
- added logging configuration
- added timestamp for logs
2026-10-10 12:45:39 +03:30
eta bea370dca2 port, acl
- container listener port changed to 1883 and 8883
- acl file renamed to acl.conf
2026-10-05 17:02:00 +03:30
eta 7772e489e0 Minor bug fix 2026-10-05 15:36:44 +03:30
eta 2e50696bb4 Minor bug fix 2026-10-05 15:20:09 +03:30
eta 25f3a40402 minor bug fix 2026-10-05 14:35:24 +03:30
eta 2bfe130d3b fixed app icon 2026-10-05 12:54:12 +03:30
eta 3cd04e3263 icon, config
- Added app icon
- added certificates and user management in app config
- added user customization files in `/share`
2026-10-05 12:45:37 +03:30
eta 00cc2beec7 added visquitto app 2026-10-04 16:40:36 +03:30
8 changed files with 308 additions and 0 deletions
+4
View File
@@ -1,6 +1,7 @@
# Changelog # Changelog
## 0.4.2 ## 0.4.2
- Certificate Common Name (CN) is now taken from each device's own - Certificate Common Name (CN) is now taken from each device's own
CSR instead of being forced to equal its `device_id`. Enables CSR instead of being forced to equal its `device_id`. Enables
deployments where many devices intentionally share one CN per deployments where many devices intentionally share one CN per
@@ -10,11 +11,14 @@
CN alongside `device_id` for each entry. CN alongside `device_id` for each entry.
## 0.4.1 ## 0.4.1
- Changed SAN default for generating server certificate - Changed SAN default for generating server certificate
- Added two new options for organizations - Added two new options for organizations
## 0.4.0 ## 0.4.0
- Replaced RSA algorithm with EC for encryption. - Replaced RSA algorithm with EC for encryption.
## 0.3.0 ## 0.3.0
- Initial release. - Initial release.
+9
View File
@@ -20,6 +20,7 @@ step 2.
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 = whatever identity you want written into the issued - Common Name = whatever identity you want written into the issued
certificate. This does NOT have to be `device_id` and does NOT have to 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 be unique per device — a common pattern is to share one CN across a
@@ -39,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",
@@ -48,6 +50,7 @@ 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.
@@ -69,26 +72,31 @@ device has its own dedicated topics here — no filtering needed, unlike
setups where many devices might share one topic. 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*
@@ -117,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",
+35
View File
@@ -0,0 +1,35 @@
# Changelog
## 0.1.0
- Initializing the Application
## 0.2.0
- Added app icon
- Improved app configuration
## 0.2.1
- Fixed app icon
## 0.2.2
- Minor bug fix
## 0.2.3
- Minor bug fix
## 0.2.4
- Minor bug fix
## 0.2.5
- Minor bug fix
## 0.3.0
- Added separated ACL's
- Improved logging capabilities
+5
View File
@@ -0,0 +1,5 @@
FROM eclipse-mosquitto:2
RUN apk add --no-cache jq
COPY run.sh /run.sh
RUN chmod a+x /run.sh
CMD ["/run.sh"]
+61
View File
@@ -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](../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](../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](../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.
+39
View File
@@ -0,0 +1,39 @@
name: Visquitto
version: "0.3.0"
slug: visquitto
description: Second private Mosquitto broker for bitopa nodes
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: []
nodes: []
require_certificate: false
cafile: mqtt-cert-manager-ca.crt
certfile: mosquitto-server.crt
keyfile: mosquitto-server.key
schema:
users:
- username: str
password: password
nodes:
log_dest: []
log_type: []
require_certificate: false
cafile: str
certfile: str
keyfile: str
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+155
View File
@@ -0,0 +1,155 @@
#!/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
protocol mqtt
allow_anonymous false
log_dest stdout
log_type error
log_type warning
log_type notice
log_timestamp_format %Y-%m-%d %H:%M:%S
persistence true
persistence_location $DATA/
max_queued_messages 8192
plugin_load acl_file /usr/lib/mosquitto_acl_file.so
plugin_load password_file /usr/lib/mosquitto_password_file.so
include_dir $SHARE
# Plain listener (host port 1993): password users only
listener 1883
protocol mqtt
plugin_use password_file
plugin_opt_password_file $PASSWD
plugin_use acl_file
plugin_opt_acl_file $DATA/acl_plain
# TLS listener (host port 9993): client certificate required
listener 8883
protocol mqtt
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 password_file
plugin_opt_password_file $PASSWD
plugin_use acl_file
plugin_opt_acl_file $DATA/acl_tls
EOF
# plain ACL
echo "# Default ACL for the plain listener: no rules, all access denied" > "$CONFIG/acl_plain"
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
EOF
# TLS ACL
echo "# Default ACL for the TLS listener: no rules, all access denied" > "$CONFIG/acl_tls"
cat > "$CONFIG/acl_tls" <<EOF
# Default rule for every certificate client. %u is the certificate CN.
pattern readwrite clients/%u/#
EOF
# ---- User customization in /share (created once, never overwritten) ----
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"