[mqtt] Fix certificate pinning (#16857)

Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
J-N-K 2024-06-08 23:22:24 +02:00 committed by Ciprian Pascu
parent 0fbe6f7ca1
commit 34107ec230
2 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -54,6 +54,10 @@ public class Pin {
return pinData;
}
public @Nullable PinMessageDigest getHashDigest() {
return hashDigest;
}
public void setLearningMode() {
this.learning = true;
this.pinData = null;