diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java index e5f29522e66..16dd1853ab5 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java @@ -83,6 +83,12 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba logger.error("Received pins hash is empty!"); return; } + PinMessageDigest hashDigest = pin.getHashDigest(); + if (hashDigest == null) { + logger.error("Received pins message digest is not set!"); + return; + } + String configKey = null; try { switch (pin.getType()) { @@ -99,7 +105,7 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba } Configuration thingConfig = editConfiguration(); - thingConfig.put(configKey, HexUtils.bytesToHex(hash)); + thingConfig.put(configKey, hashDigest.getMethod() + ":" + HexUtils.bytesToHex(hash)); updateConfiguration(thingConfig); } diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/internal/ssl/Pin.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/internal/ssl/Pin.java index 9009b18d006..134f53408a3 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/internal/ssl/Pin.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/internal/ssl/Pin.java @@ -54,6 +54,10 @@ public class Pin { return pinData; } + public @Nullable PinMessageDigest getHashDigest() { + return hashDigest; + } + public void setLearningMode() { this.learning = true; this.pinData = null;