Skip to content

Commit

Permalink
refactor(nm): take into account changes in NetworkProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdibi committed Jan 10, 2024
1 parent e1fb632 commit 870ae5f
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,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 (CertificateEncodingException | ClassCastException e) {
} catch (CertificateEncodingException e) {
throw new NoSuchElementException(
String.format("Unable to find or decode Client Certificate for interface \"%s\"", deviceId));
String.format("Unable to decode Client Certificate for interface \"%s\"", deviceId));
}

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<>(convertToPem(privateKey.getEncoded())));
} else {
throw new NoSuchElementException("Unable to find or decode Private Key");
}
} catch (ClassCastException e) {
throw new NoSuchElementException("Unable to find Private Key");
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<>(convertToPem(privateKey.getEncoded())));
} else {
throw new NoSuchElementException("Unable to decode Private Key");
}

Optional<Password> privateKeyPassword = props.getOpt(Password.class,
Expand All @@ -229,9 +225,9 @@ private static void create8021xCaCertAndAnonIdentity(NetworkProperties props, St
try {
Certificate caCert = props.get(Certificate.class, "net.interface.%s.config.802-1x.ca-cert-name", deviceId);
settings.put("ca-cert", new Variant<>(caCert.getEncoded()));
} catch (CertificateEncodingException | ClassCastException e) {
} catch (CertificateEncodingException e) {
throw new NoSuchElementException(
String.format("Unable to find or decode CA Certificate for interface %s", deviceId));
String.format("Unable to decode CA Certificate for interface %s", deviceId));
}

Optional<Password> caCertPassword = props.getOpt(Password.class,
Expand Down

0 comments on commit 870ae5f

Please sign in to comment.