8000 [26.2.x] Unable to configure TLS reloading in Keycloak version 26.2.0 or later by mabartos · Pull Request #40819 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[26.2.x] Unable to configure TLS reloading in Keycloak version 26.2.0 or later #40819

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

Merged
merged 2 commits into from
Jul 1, 2025
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
8000 Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public static PropertyMapper<?>[] getHttpPropertyMappers() {
.build(),
fromOption(HttpOptions.HTTPS_CERTIFICATES_RELOAD_PERIOD)
.to("quarkus.http.ssl.certificate.reload-period")
// -1 means no reload
.transformer((value, context) -> "-1".equals(value) ? null : value)
.transformer(HttpPropertyMappers::transformNegativeReloadPeriod)
.paramLabel("reload period")
.build(),
fromOption(HttpOptions.HTTPS_CERTIFICATE_FILE)
Expand Down Expand Up @@ -174,6 +173,11 @@ private static String getHttpEnabledTransformer(String value, ConfigSourceInterc
return isHttpEnabled(value) ? "enabled" : "disabled";
}

static String transformNegativeReloadPeriod(String value, ConfigSourceInterceptorContext context) {
// -1 means no reload
return "-1".equals(value) ? null : value;
}

private static boolean isHttpEnabled(String value) {
if (Environment.isDevMode() || Environment.isNonServerMode()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public static PropertyMapper<?>[] getManagementPropertyMappers() {
fromOption(ManagementOptions.HTTPS_MANAGEMENT_CERTIFICATES_RELOAD_PERIOD)
.mapFrom(HttpOptions.HTTPS_CERTIFICATES_RELOAD_PERIOD)
.to("quarkus.management.ssl.certificate.reload-period")
// -1 means no reload
.transformer((value, context) -> "-1".equals(value) ? null : value)
.transformer(HttpPropertyMappers::transformNegativeReloadPeriod)
.paramLabel("reload period")
.build(),
fromOption(ManagementOptions.HTTPS_MANAGEMENT_CERTIFICATE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ private ConfigValue transformValue(String name, ConfigValue configValue, ConfigS
String mappedValue = value;

boolean mapped = false;
var theMapper = parentValue ? this.parentMapper : this.mapper;
// fall back to the transformer when no mapper is explicitly specified in .mapFrom()
var theMapper = parentValue && parentMapper != null ? this.parentMapper : this.mapper;
if (theMapper != null && (!name.equals(getFrom()) || parentValue)) {
mappedValue = theMapper.apply(value, context);
mapped = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ public void testNegativeArgument() {
assertEquals(CommandLine.ExitCode.OK, nonRunningPicocli.exitCode);
assertEquals("1h",
nonRunningPicocli.config.getConfigValue("quarkus.http.ssl.certificate.reload-period").getValue());
assertEquals("1h",
nonRunningPicocli.config.getConfigValue("quarkus.management.ssl.certificate.reload-period").getValue());

nonRunningPicocli = pseudoLaunch("start-dev", "--https-certificates-reload-period=-1");
assertEquals(CommandLine.ExitCode.OK, nonRunningPicocli.exitCode);
assertNull(nonRunningPicocli.config.getConfigValue("quarkus.http.ssl.certificate.reload-period").getValue());
assertNull(nonRunningPicocli.config.getConfigValue("quarkus.management.ssl.certificate.reload-period").getValue());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -172,6 +173,19 @@ protected void assertExternalConfig(Map<String, String> expectedValues) {
expectedValues.forEach(this::assertExternalConfig);
}

protected void assertConfigNull(String key, boolean isExternal) {
Function<String, ConfigValue> getConfig = isExternal ? Configuration::getConfigValue : Configuration::getKcConfigValue;
assertThat(String.format("We expect that the value is null for key '%s'", key), getConfig.apply(key).getValue(), nullValue());
}

protected void assertConfigNull(String key) {
assertConfigNull(key, false);
}

protected void assertExternalConfigNull(String key) {
assertConfigNull(key, true);
}

protected static void addPersistedConfigValues(Map<String, String> values) {
var configValueProps = PersistedConfigSource.getInstance().getConfigValueProperties();
values.forEach((k, v) -> configValueProps.put(k,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,23 @@ public void testKeystoreConfigSourcePropertyMapping() {
@Test
public void testReloadPeriod() {
ConfigArgsConfigSource.setCliArgs("");
assertEquals("1h", createConfig().getConfigValue("quarkus.http.ssl.certificate.reload-period").getValue());
initConfig();
assertExternalConfig(Map.of(
"quarkus.http.ssl.certificate.reload-period", "1h",
"quarkus.management.ssl.certificate.reload-period", "1h"
));

ConfigArgsConfigSource.setCliArgs("--https-certificates-reload-period=-1");
assertNull(createConfig().getConfigValue("quarkus.http.ssl.certificate.reload-period").getValue());
initConfig();
assertExternalConfigNull("quarkus.http.ssl.certificate.reload-period");
assertExternalConfigNull("quarkus.management.ssl.certificate.reload-period");

ConfigArgsConfigSource.setCliArgs("--https-certificates-reload-period=2h");
assertEquals("2h", createConfig().getConfigValue("quarkus.http.ssl.certificate.reload-period").getValue());
initConfig();
assertExternalConfig(Map.of(
"quarkus.http.ssl.certificate.reload-period", "2h",
"quarkus.management.ssl.certificate.reload-period", "2h"
));
}

@Test
Expand Down
0