Skip to content

Commit

Permalink
backwards compatible when no encryption key was added in previous config
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricve committed Oct 20, 2023
1 parent 0c70ab6 commit 48d933a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion machinery/src/models/MQTT.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
2 changes: 1 addition & 1 deletion machinery/src/routers/mqtt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 48d933a

Please sign in to comment.