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 settings prefix for realm truststore password #42336

Merged
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 @@ -117,7 +117,7 @@ public class SSLConfigurationSettings {
public static final Setting<SecureString> LEGACY_TRUSTSTORE_PASSWORD_PROFILES = Setting.affixKeySetting("transport.profiles.",
"xpack.security.ssl.truststore.password", LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE);
public static final Function<String, Setting.AffixSetting<SecureString>> LEGACY_TRUST_STORE_PASSWORD_REALM = realmType ->
Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "truststore.password",
Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "ssl.truststore.password",
LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE);

public static final Function<String, Setting<SecureString>> TRUSTSTORE_PASSWORD_TEMPLATE = key ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
*/
package org.elasticsearch.xpack.core.ssl;

import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;

import java.util.Arrays;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;

public class SSLConfigurationSettingsTests extends ESTestCase {

Expand Down Expand Up @@ -91,4 +93,19 @@ public void testEmptySettingsParsesToDefaults() {
assertThat(SSLConfigurationSettings.getKeyStoreType(ssl.truststoreType, settings, null), is("jks"));
}

public void testRealmSettingPrefixes() {
SSLConfigurationSettings.getRealmSettings("_type").forEach(affix -> {
final String key = affix.getConcreteSettingForNamespace("_name").getKey();
assertThat(key, startsWith("xpack.security.authc.realms._type._name.ssl."));
});
}

public void testProfileSettingPrefixes() {
SSLConfigurationSettings.getProfileSettings().forEach(affix -> {
assertThat(affix, instanceOf(Setting.AffixSetting.class));
final String key = ((Setting.AffixSetting) affix).getConcreteSettingForNamespace("_name").getKey();
assertThat(key, startsWith("transport.profiles._name.xpack.security.ssl."));
});
}

}