This commit is contained in:
Michael Hansen
2020-04-10 13:08:26 -04:00
10 changed files with 157 additions and 15 deletions
+9 -1
View File
@@ -69,7 +69,15 @@ Add to your [profile](profiles.md):
"username": "",
"port": 1883,
"password": "",
"site_id": "default"
"site_id": "default",
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
}
```
+9 -1
View File
@@ -44,7 +44,15 @@ Add to your [profile](profiles.md):
"username": "",
"port": 1883,
"password": "",
"site_id": "default"
"site_id": "default",
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
}
```
+9 -1
View File
@@ -86,7 +86,15 @@ Add to your [profile](profiles.md):
"username": "",
"port": 1883,
"password": "",
"site_id": "default"
"site_id": "default",
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
}
```
+16 -8
View File
@@ -93,14 +93,22 @@ Add to your [profile](profiles.md):
```json
"mqtt": {
"enabled": true,
"host": "localhost",
"username": "",
"password": "",
"port": 1883,
"reconnect_sec": 5,
"site_id": "default",
"publish_intents": true
"enabled": true,
"host": "localhost",
"username": "",
"password": "",
"port": 1883,
"reconnect_sec": 5,
"site_id": "default",
"publish_intents": true,
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
}
```
+9 -1
View File
@@ -181,7 +181,15 @@ Add to your [profile](profiles.md):
"username": "",
"port": 1883,
"password": "",
"site_id": "default"
"site_id": "default",
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
}
```
+9 -1
View File
@@ -119,7 +119,15 @@
"publish_intents": true,
"reconnect_sec": 5,
"site_id": "default",
"username": ""
"username": "",
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
},
"rhasspy": {
"listen_on_start": true,
+23
View File
@@ -48,6 +48,7 @@ class HermesMqtt(RhasspyActor):
self.password = None
self.reconnect_sec = 5
self.publish_intents = True
self.tls = { "enabled": False }
# -------------------------------------------------------------------------
@@ -66,6 +67,7 @@ class HermesMqtt(RhasspyActor):
self.password = self.profile.get("mqtt.password", None)
self.reconnect_sec = self.profile.get("mqtt.reconnect_sec", 5)
self.publish_intents = self.profile.get("mqtt.publish_intents", True)
self.tls = self.profile.get("mqtt.tls", { "enabled": False })
if self.profile.get("mqtt.enabled", False):
self.transition("connecting")
@@ -84,6 +86,27 @@ class HermesMqtt(RhasspyActor):
self.client.on_message = self.on_message
self.client.on_disconnect = self.on_disconnect
if pydash.get(self.tls, "enabled", False):
import ssl
allowed_cert_reqs = {
"CERT_REQUIRED": ssl.CERT_REQUIRED,
"CERT_OPTIONAL": ssl.CERT_OPTIONAL,
"CERT_NONE": ssl.CERT_NONE
}
self.client.tls_set(
ca_certs=pydash.get(self.tls, "ca_certs", None),
cert_reqs=pydash.get(
allowed_cert_reqs,
pydash.get(self.tls, "cert_reqs", "CERT_REQUIRED"),
ssl.CERT_REQUIRED
),
certfile=pydash.get(self.tls, "certfile", None),
ciphers=pydash.get(self.tls, "ciphers", None),
keyfile=pydash.get(self.tls, "keyfile", None),
tls_version=ssl.PROTOCOL_TLS
)
if self.username:
self._logger.debug("Logging in as %s", self.username)
self.client.username_pw_set(self.username, self.password)
+12 -1
View File
@@ -417,7 +417,18 @@
"reconnect_sec": { "type": "integer", "min": 0 },
"site_id": { "type": "string" },
"username": { "type": "string" },
"publish_intents": { "type": "boolean" }
"publish_intents": { "type": "boolean" },
"tls": {
"type": "dict",
"schema": {
"enabled": { "type": "boolean" },
"ca_certs": { "type": "string" },
"cert_reqs": { "type": "string" },
"certfile": { "type": "string" },
"ciphers": { "type": "string" },
"keyfile": { "type": "string" }
}
}
}
},
+9 -1
View File
@@ -109,7 +109,15 @@ const profileDefaults = {
"reconnect_sec": 5,
"site_id": "default",
"username": "",
"publish_intents": true
"publish_intents": true,
"tls": {
"enabled": false,
"ca_certs": "",
"cert_reqs": "CERT_REQUIRED",
"certfile": "",
"ciphers": "",
"keyfile": ""
}
},
"rhasspy": {
"default_profile": "en",
+52
View File
@@ -70,6 +70,58 @@
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<input id="mqtt-tls-enabled" type="checkbox" v-model="profile.mqtt.tls.enabled" :disabled="!profile.mqtt.enabled">
<label for="mqtt-tls-enabled" class="col-form-label">Enable MQTT over TLS</label>
</div>
</div>
<template v-if="profile.mqtt.tls.enabled">
<div class="form-group">
<div class="form-row">
<label for="mqtt-tls-ca_certs" class="col-form-label">ca_certs</label>
<div class="col-sm-auto">
<input id="mqtt-tls-ca_certs" type="text" class="form-control" v-model="profile.mqtt.tls.ca_certs" :disabled="!profile.mqtt.enabled">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<label for="mqtt-tls-cert_reqs" class="col-form-label">cert_reqs</label>
<div class="col-sm-auto">
<select id="mqtt-tls-cert_reqs" v-model="profile.mqtt.tls.cert_reqs" :disabled="!profile.mqtt.enabled">
<option value="CERT_REQUIRED" default>CERT_REQUIRED</option>
<option value="CERT_OPTIONAL">CERT_OPTIONAL</option>
<option value="CERT_NONE">CERT_NONE</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<label for="mqtt-tls-certfile" class="col-form-label">certfile</label>
<div class="col-sm-auto">
<input id="mqtt-tls-certfile" type="text" class="form-control" v-model="profile.mqtt.tls.certfile" :disabled="!profile.mqtt.enabled">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<label for="mqtt-tls-ciphers" class="col-form-label">ciphers</label>
<div class="col-sm-auto">
<input id="mqtt-tls-ciphers" type="text" class="form-control" v-model="profile.mqtt.tls.ciphers" :disabled="!profile.mqtt.enabled">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<label for="mqtt-tls-keyfile" class="col-form-label">keyfile</label>
<div class="col-sm-auto">
<input id="mqtt-tls-keyfile" type="text" class="form-control" v-model="profile.mqtt.tls.keyfile" :disabled="!profile.mqtt.enabled">
</div>
</div>
</div>
</template>
<div class="form-group">
<div class="form-row">
<input type="checkbox" id="mqtt-publish_intents" v-model="profile.mqtt.publish_intents" :disabled="!profile.mqtt.enabled">