8000 [Quarkus 4] Configure HTTPS SNI through the Quarkus TLS registry by Pepo48 · Pull Request #54616 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
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 @@ -16,6 +16,7 @@
import org.keycloak.config.Option;
import org.keycloak.config.OptionBuilder;
import org.keycloak.config.OptionsUtil;
import org.keycloak.config.ProxyOptions;
import org.keycloak.config.SecurityOptions;
import org.keycloak.quarkus.runtime.Environment;
import org.keycloak.quarkus.runtime.Messages;
Expand Down Expand Up @@ -150,10 +151,12 @@ public List<PropertyMapper<?>> getPropertyMappers() {
addKeyStoreMappers(mappers);
addTrustStoreMappers(mappers);

// SNI is enabled via KeycloakHttpServerOptionsCustomizer to bypass TLS Registry's
// overly strict validation that rejects SNI with single-alias keystores (quarkusio/quarkus#55943).
// Keycloak uses SNI for misdirected request detection (HTTP 421), not for cert selection.
// Once that issue is fixed, move SNI back to a config property mapper here.
mappers.add(fromOption(HttpOptions.HTTPS_SNI_ENABLED)
.to(QUARKUS_HTTPS_SNI)
.transformer((v, c) -> isHttpsEnabled()
? Boolean.toString(Configuration.getConfigValue(ProxyOptions.PROXY_HEADERS).getValue() == null)
: null)
.build());

mappers.addAll(List.of(
fromOption(HttpOptions.HTTP_MAX_QUEUED_REQUESTS)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,26 @@ public void testMtlsEnabledMapsToRuntimeProperty() {
}

@Test
public void testSniNotSetViaConfig() {
// SNI is enabled via KeycloakHttpServerOptionsCustomizer, not via config property
public void testSniEnabledForDirectHttps() {
var config = createConfigFromCliArguments("--https-certificate-file=\\some\\file");
assertEquals("true", config.getConfigValue(HttpPropertyMappers.QUARKUS_HTTPS_SNI).getValue());
}

@Test
public void testSniDisabledWithForwardedProxyHeaders() {
var config = createConfigFromCliArguments("--https-certificate-file=/cert.pem", "--proxy-headers=forwarded");
assertEquals("false", config.getConfigValue(HttpPropertyMappers.QUARKUS_HTTPS_SNI).getValue());
}

@Test
public void testSniDisabledWithXForwardedProxyHeaders() {
var config = createConfigFromCliArguments("--https-certificate-file=/cert.pem", "--proxy-headers=xforwarded");
assertEquals("false", config.getConfigValue(HttpPropertyMappers.QUARKUS_HTTPS_SNI).getValue());
}

@Test
public void testSniNotSetWithoutHttps() {
var config = createConfigFromCliArguments();
assertNull(config.getConfigValue(HttpPropertyMappers.QUARKUS_HTTPS_SNI).getValue());
}

Expand Down
Loading
0