From 2ff3a7f74d782ab53a9a60418a96c573406b3c4b Mon Sep 17 00:00:00 2001 From: Gregory Ivo Date: Thu, 12 Oct 2023 09:45:49 -0400 Subject: [PATCH] fix: removed generic exception logging, and changed exceptions --- .../nm/configuration/NMSettingsConverter.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java index acfe37ba20b..cb23356e346 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java @@ -18,6 +18,7 @@ import java.nio.charset.StandardCharsets; import java.security.PrivateKey; import java.security.cert.Certificate; +import java.security.cert.CertificateEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -179,16 +180,17 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map Certificate clientCert = props.get(Certificate.class, "net.interface.%s.config.802-1x.client-cert-name", deviceId); settings.put("client-cert", new Variant<>(clientCert.getEncoded())); - } catch (Exception e) { - logger.error("Unable to find or decode Client Certificate", e); + } catch (CertificateEncodingException e) { + logger.error("Unable to find or decode Client Certificate"); } - try { - PrivateKey privateKey = props.get(PrivateKey.class, "net.interface.%s.config.802-1x.private-key-name", - deviceId); + PrivateKey privateKey = props.get(PrivateKey.class, "net.interface.%s.config.802-1x.private-key-name", + deviceId); + + if (privateKey.getEncoded() != null) { settings.put("private-key", new Variant<>(privateKey.getEncoded())); - } catch (Exception e) { - logger.error("Unable to find or decode Private Key", e); + } else { + logger.error("Unable to find or decode Private Key"); } Optional privateKeyPassword = props.getOpt(Password.class,