Compare commits

...

1 Commits

Author SHA1 Message Date
Cedric Verstraeten
48d933a561 backwards compatible when no encryption key was added in previous config 2023-10-20 14:35:09 +02:00
2 changed files with 2 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ func PackageMQTTMessage(configuration *Configuration, msg Message) ([]byte, erro
// At the moment we don't do the encryption part, but we'll implement it
// once the legacy methods (subscriptions are moved).
msg.Encrypted = false
if configuration.Config.Encryption.Enabled {
if configuration.Config.Encryption != nil && configuration.Config.Encryption.Enabled {
msg.Encrypted = true
}
msg.PublicKey = ""

View File

@@ -168,7 +168,7 @@ func MQTTListenerHandler(mqttClient mqtt.Client, hubKey string, configDirectory
// Messages might be encrypted, if so we'll
// need to decrypt them.
var payload models.Payload
if message.Encrypted {
if message.Encrypted && configuration.Config.Encryption != nil && configuration.Config.Encryption.Enabled {
encryptedValue := message.Payload.EncryptedValue
if len(encryptedValue) > 0 {
symmetricKey := configuration.Config.Encryption.SymmetricKey