Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added catch to exception to prevent failure when keystores don't exist [backport release-5.4.0] #5031

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map
deviceId);
settings.put("client-cert", new Variant<>(clientCert.getEncoded()));
} catch (CertificateEncodingException e) {
logger.error("Unable to find or decode Client Certificate");
logger.error("Unable to decode Client Certificate");
} catch (ClassCastException e) {
logger.error("Unable to find Client Certificate");
}

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()));
} else {
logger.error("Unable to find or decode Private Key");
try {
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()));
} else {
logger.error("Unable to find or decode Private Key");
}
} catch (ClassCastException e) {
logger.error("Unable to find Private Key");
}

Optional<Password> privateKeyPassword = props.getOpt(Password.class,
Expand Down Expand Up @@ -306,7 +311,7 @@ public static Map<String, Variant<?>> buildIpv4Settings(NetworkProperties props,
return settings;
}

public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props, String deviceId,
public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props, String deviceId,
SemanticVersion nmVersion) {

// buildIpv6Settings doesn't support Unmanaged status. Therefore if ip6.status
Expand Down Expand Up @@ -404,9 +409,9 @@ public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props,
logger.warn("Unexpected ip status received: \"{}\". Ignoring", ip6Status);
}

Optional<Integer> mtu = props.getOpt(Integer.class, "net.interface.%s.config.ip6.mtu", deviceId);
Optional<Integer> mtu = props.getOpt(Integer.class, "net.interface.%s.config.ip6.mtu", deviceId);
if (nmVersion.isGreaterEqualThan("1.40")) {
//ipv6.mtu only supported in NetworkManager 1.40 and above
// ipv6.mtu only supported in NetworkManager 1.40 and above
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));
} else {
logger.warn("Ignoring parameter ipv6.mtu: NetworkManager 1.40 or above is required");
Expand Down Expand Up @@ -440,7 +445,7 @@ public static Map<String, Variant<?>> build80211WirelessSettings(NetworkProperti

Optional<Integer> mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId);
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));

return settings;
}

Expand Down Expand Up @@ -536,7 +541,7 @@ public static Map<String, Variant<?>> buildGsmSettings(NetworkProperties props,

Optional<Integer> mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId);
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));

return settings;
}

Expand Down Expand Up @@ -572,12 +577,12 @@ public static Map<String, Variant<?>> buildVlanSettings(NetworkProperties props,
settings.put("egress-priority-map", new Variant<>(egressMap.orElse(new ArrayList<>()), listType));
return settings;
}

public static Map<String, Variant<?>> buildEthernetSettings(NetworkProperties props, String deviceId) {
Map<String, Variant<?>> settings = new HashMap<>();
Optional<Integer> mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId);
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));
return settings;
return settings;
}

public static Map<String, Variant<?>> buildConnectionSettings(Optional<Connection> connection, String iface,
Expand Down