Skip to content

Commit dcf2929

Browse files
authored
Fix settings prefix for realm truststore password (#42336)
As part of #30241 realm settings were changed to be true affix settings. In the process of this change, the "ssl." prefix was lost from the realm truststore password. It should be: xpack.security.authc.realms.<type>.<name>.ssl.truststore.password Due to a mismatch between the way we define SSL settings and load SSL contexts, there was no way to define this legacy password setting in a realm config. The settings validation would reject "ssl.truststore.password" but the SSL service would ignore "truststore.password" Resolves: #41663
1 parent 23e4d46 commit dcf2929

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class SSLConfigurationSettings {
117117
public static final Setting<SecureString> LEGACY_TRUSTSTORE_PASSWORD_PROFILES = Setting.affixKeySetting("transport.profiles.",
118118
"xpack.security.ssl.truststore.password", LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE);
119119
public static final Function<String, Setting.AffixSetting<SecureString>> LEGACY_TRUST_STORE_PASSWORD_REALM = realmType ->
120-
Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "truststore.password",
120+
Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "ssl.truststore.password",
121121
LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE);
122122

123123
public static final Function<String, Setting<SecureString>> TRUSTSTORE_PASSWORD_TEMPLATE = key ->

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettingsTests.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
*/
66
package org.elasticsearch.xpack.core.ssl;
77

8+
import org.elasticsearch.common.settings.Setting;
89
import org.elasticsearch.common.settings.Settings;
910
import org.elasticsearch.test.ESTestCase;
1011

1112
import javax.net.ssl.KeyManagerFactory;
1213
import javax.net.ssl.TrustManagerFactory;
13-
1414
import java.util.Arrays;
1515

16+
import static org.hamcrest.Matchers.instanceOf;
1617
import static org.hamcrest.Matchers.is;
18+
import static org.hamcrest.Matchers.startsWith;
1719

1820
public class SSLConfigurationSettingsTests extends ESTestCase {
1921

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

96+
public void testRealmSettingPrefixes() {
97+
SSLConfigurationSettings.getRealmSettings("_type").forEach(affix -> {
98+
final String key = affix.getConcreteSettingForNamespace("_name").getKey();
99+
assertThat(key, startsWith("xpack.security.authc.realms._type._name.ssl."));
100+
});
101+
}
102+
103+
public void testProfileSettingPrefixes() {
104+
SSLConfigurationSettings.getProfileSettings().forEach(affix -> {
105+
assertThat(affix, instanceOf(Setting.AffixSetting.class));
106+
final String key = ((Setting.AffixSetting) affix).getConcreteSettingForNamespace("_name").getKey();
107+
assertThat(key, startsWith("transport.profiles._name.xpack.security.ssl."));
108+
});
109+
}
110+
94111
}

0 commit comments

Comments
 (0)