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(nm): remove unusable 802.1x password parameters #5097

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
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 @@ -204,14 +204,7 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map
} else {
logger.error("Unable to decode Private Key for interface \"{}\"", deviceId);
}

Optional<Password> privateKeyPassword = props.getOpt(Password.class,
"net.interface.%s.config.802-1x.private-key-password", deviceId);

privateKeyPassword.ifPresent(value -> settings.put("private-key-password", new Variant<>(value.toString())));

settings.put("private-key-password-flags", new Variant<>(NM_SECRET_FLAGS_NOT_REQUIRED));

}

private static void create8021xOptionalCaCertAndAnonIdentity(NetworkProperties props, String deviceId,
Expand All @@ -230,10 +223,6 @@ private static void create8021xOptionalCaCertAndAnonIdentity(NetworkProperties p
logger.warn("Unable to decode CA Certificate for interface \"{}\", caused by: ", deviceId, e);
}
});

Optional<Password> caCertPassword = props.getOpt(Password.class,
"net.interface.%s.config.802-1x.ca-cert-password", deviceId);
caCertPassword.ifPresent(value -> settings.put("ca-cert-password", new Variant<>(value.toString())));
}

private static void create8021xMschapV2(NetworkProperties props, String deviceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ public void build8021xSettingsShouldWorkWithTtlsAndMschapV2AndOptionalParams() {
givenMapWith("net.interface.wlan0.config.802-1x.anonymous-identity", "anonymous-identity-test-var");
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-name",
buildMockedCertificateWithCert("binary ca cert"));
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-password", new Password("secure-password"));
givenMapWith("net.interface.wlan0.config.802-1x.identity", "example-user-name");
givenMapWith("net.interface.wlan0.config.802-1x.password", new Password("secure-test-password-123!@#"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);
Expand All @@ -580,10 +579,10 @@ public void build8021xSettingsShouldWorkWithTtlsAndMschapV2AndOptionalParams() {
thenResultingMapContains("phase2-auth", "mschapv2");
thenResultingMapContains("anonymous-identity", "anonymous-identity-test-var");
thenResultingMapContainsBytes("ca-cert", "binary ca cert");
thenResultingMapContains("ca-cert-password", "secure-password");
thenResultingMapContains("identity", "example-user-name");
thenResultingMapContains("password", "secure-test-password-123!@#");

thenResultingMapNotContains("ca-cert-password");
}

@Test
Expand All @@ -599,12 +598,13 @@ public void build8021xSettingsShouldWorkWithPeapAndMschapV2() {
thenNoExceptionOccurred();

thenResultingMapContainsArray("eap", new Variant<>(new String[] { "peap" }).getValue());
thenResultingMapNotContains("anonymous-identity");
thenResultingMapNotContains("ca-cert");
thenResultingMapNotContains("ca-cert-password");
thenResultingMapContains("phase2-auth", "mschapv2");
thenResultingMapContains("identity", "example-user-name");
thenResultingMapContains("password", "secure-test-password-123!@#");

thenResultingMapNotContains("anonymous-identity");
thenResultingMapNotContains("ca-cert");
thenResultingMapNotContains("ca-cert-password");
}

@Test
Expand All @@ -613,7 +613,6 @@ public void build8021xSettingsShouldWorkWithPeapAndMschapV2AndCertificates() {
givenMapWith("net.interface.wlan0.config.802-1x.anonymous-identity", "anonymous-identity-test-var");
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-name",
buildMockedCertificateWithCert("binary ca cert"));
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-password", new Password("secure-password"));
givenMapWith("net.interface.wlan0.config.802-1x.innerAuth", "Kura8021xInnerAuthMschapv2");
givenMapWith("net.interface.wlan0.config.802-1x.identity", "example-user-name");
givenMapWith("net.interface.wlan0.config.802-1x.password", new Password("secure-test-password-123!@#"));
Expand All @@ -626,10 +625,11 @@ public void build8021xSettingsShouldWorkWithPeapAndMschapV2AndCertificates() {
thenResultingMapContainsArray("eap", new Variant<>(new String[] { "peap" }).getValue());
thenResultingMapContains("anonymous-identity", "anonymous-identity-test-var");
thenResultingMapContainsBytes("ca-cert", "binary ca cert");
thenResultingMapContains("ca-cert-password", "secure-password");
thenResultingMapContains("phase2-auth", "mschapv2");
thenResultingMapContains("identity", "example-user-name");
thenResultingMapContains("password", "secure-test-password-123!@#");

thenResultingMapNotContains("ca-cert-password");
}

@Test
Expand All @@ -652,7 +652,6 @@ public void build8021xSettingsShouldWorkWithTls() {
buildMockedCertificateWithCert("binary client cert"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-name",
buildMockedPrivateKeyWithKey("binary private key"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-password", new Password("secure-password"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0");
Expand All @@ -666,7 +665,10 @@ public void build8021xSettingsShouldWorkWithTls() {
thenResultingMapContainsBytes("client-cert", "binary client cert");
thenResultingMapContainsBytes("private-key",
"-----BEGIN PRIVATE KEY-----\nYmluYXJ5IHByaXZhdGUga2V5\n-----END PRIVATE KEY-----\n");
thenResultingMapContains("private-key-password", "secure-password");

thenResultingMapNotContains("private-key-password");
thenResultingMapNotContains("ca-cert-password");
thenResultingMapNotContains("client-cert-password");
}

@Test
Expand All @@ -679,7 +681,6 @@ public void build8021xSettingsShouldThrowWithTlsWithNullPrivateKey() {
givenMapWith("net.interface.wlan0.config.802-1x.client-cert-name",
buildMockedCertificateWithCert("binary client cert"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-name", null);
givenMapWith("net.interface.wlan0.config.802-1x.private-key-password", new Password("secure-password"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0");
Expand All @@ -697,7 +698,6 @@ public void build8021xSettingsShouldThrowWithTlsWithWrongTypePrivateKey() {
givenMapWith("net.interface.wlan0.config.802-1x.client-cert-name",
buildMockedCertificateWithCert("binary client cert"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-name", "");
givenMapWith("net.interface.wlan0.config.802-1x.private-key-password", new Password("secure-password"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0");
Expand All @@ -715,7 +715,6 @@ public void build8021xSettingsShouldWorkWithTlsWithNullCACert() {
buildMockedCertificateWithCert("binary client cert"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-name",
buildMockedPrivateKeyWithKey("binary private key"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-password", new Password("secure-password"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0");
Expand All @@ -727,10 +726,12 @@ public void build8021xSettingsShouldWorkWithTlsWithNullCACert() {
thenResultingMapContainsBytes("client-cert", "binary client cert");
thenResultingMapContainsBytes("private-key",
"-----BEGIN PRIVATE KEY-----\nYmluYXJ5IHByaXZhdGUga2V5\n-----END PRIVATE KEY-----\n");
thenResultingMapContains("private-key-password", "secure-password");

thenResultingMapNotContains("phase2-auth");
thenResultingMapNotContains("ca-cert");
thenResultingMapNotContains("private-key-password");
thenResultingMapNotContains("ca-cert-password");
thenResultingMapNotContains("client-cert-password");
}

@Test
Expand All @@ -744,7 +745,6 @@ public void build8021xSettingsShouldWorkWithTlsWithWrongTypeCACert() {
buildMockedCertificateWithCert("binary client cert"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-name",
buildMockedPrivateKeyWithKey("binary private key"));
givenMapWith("net.interface.wlan0.config.802-1x.private-key-password", new Password("secure-password"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0");
Expand All @@ -756,10 +756,12 @@ public void build8021xSettingsShouldWorkWithTlsWithWrongTypeCACert() {
thenResultingMapContainsBytes("client-cert", "binary client cert");
thenResultingMapContainsBytes("private-key",
"-----BEGIN PRIVATE KEY-----\nYmluYXJ5IHByaXZhdGUga2V5\n-----END PRIVATE KEY-----\n");
thenResultingMapContains("private-key-password", "secure-password");

thenResultingMapNotContains("phase2-auth");
thenResultingMapNotContains("ca-cert");
thenResultingMapNotContains("private-key-password");
thenResultingMapNotContains("ca-cert-password");
thenResultingMapNotContains("client-cert-password");
}

@Test
Expand Down Expand Up @@ -1447,7 +1449,6 @@ public void buildSettingsShouldWorkWith8021x() {
givenMapWith("net.interface.wlan0.config.802-1x.anonymous-identity", "anonymous-identity-test-var");
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-name",
buildMockedCertificateWithCert("binary ca cert"));
givenMapWith("net.interface.wlan0.config.802-1x.ca-cert-password", new Password("secure-password"));
givenMapWith("net.interface.wlan0.config.802-1x.identity", "example-user-name");
givenMapWith("net.interface.wlan0.config.802-1x.password", new Password("secure-test-password-123!@#"));
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);
Expand All @@ -1472,9 +1473,10 @@ public void buildSettingsShouldWorkWith8021x() {
thenResultingBuildAllMapContains("802-1x", "phase2-auth", "mschapv2");
thenResultingBuildAllMapContains("802-1x", "anonymous-identity", "anonymous-identity-test-var");
thenResultingBuildAllMapContainsBytes("802-1x", "ca-cert", "binary ca cert");
thenResultingBuildAllMapContains("802-1x", "ca-cert-password", "secure-password");
thenResultingBuildAllMapContains("802-1x", "identity", "example-user-name");
thenResultingBuildAllMapContains("802-1x", "password", "secure-test-password-123!@#");

thenResultingBuildAllMapNotContains("802-1x", "ca-cert-password");
}

@Test
Expand Down
Loading