diff --git a/extensions/keycloak-admin-client/deployment/src/main/java/io/quarkus/keycloak/adminclient/deployment/KeycloakAdminClientProcessor.java b/extensions/keycloak-admin-client/deployment/src/main/java/io/quarkus/keycloak/adminclient/deployment/KeycloakAdminClientProcessor.java index f5ecf30d4fdaa..05a8820f0bb74 100644 --- a/extensions/keycloak-admin-client/deployment/src/main/java/io/quarkus/keycloak/adminclient/deployment/KeycloakAdminClientProcessor.java +++ b/extensions/keycloak-admin-client/deployment/src/main/java/io/quarkus/keycloak/adminclient/deployment/KeycloakAdminClientProcessor.java @@ -16,8 +16,10 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Produce; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem; +import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem; import io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer; @@ -45,6 +47,13 @@ ReflectiveClassBuildItem reflect() { .build(); } + @Record(ExecutionTime.STATIC_INIT) + @Produce(ServiceStartBuildItem.class) + @BuildStep + public void integrate(ResteasyKeycloakAdminClientRecorder recorder) { + recorder.setClientProvider(); + } + @Record(ExecutionTime.RUNTIME_INIT) @BuildStep(onlyIf = KeycloakAdminClientInjectionEnabled.class) public void registerKeycloakAdminClientBeans(ResteasyKeycloakAdminClientRecorder recorder, diff --git a/extensions/keycloak-admin-client/runtime/src/main/java/io/quarkus/keycloak/adminclient/ResteasyKeycloakAdminClientRecorder.java b/extensions/keycloak-admin-client/runtime/src/main/java/io/quarkus/keycloak/adminclient/ResteasyKeycloakAdminClientRecorder.java index f4866e2d1197b..5ffe9c6f0df6d 100644 --- a/extensions/keycloak-admin-client/runtime/src/main/java/io/quarkus/keycloak/adminclient/ResteasyKeycloakAdminClientRecorder.java +++ b/extensions/keycloak-admin-client/runtime/src/main/java/io/quarkus/keycloak/adminclient/ResteasyKeycloakAdminClientRecorder.java @@ -4,8 +4,13 @@ import java.util.function.Supplier; +import javax.net.ssl.SSLContext; +import javax.ws.rs.client.Client; + +import org.keycloak.admin.client.ClientBuilderWrapper; import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.KeycloakBuilder; +import org.keycloak.admin.client.spi.ResteasyClientClassicProvider; import io.quarkus.keycloak.admin.client.common.KeycloakAdminClientConfig; import io.quarkus.runtime.RuntimeValue; @@ -50,4 +55,15 @@ public Keycloak get() { } }; } + + public void setClientProvider() { + Keycloak.setClientProvider(new ResteasyClientClassicProvider() { + @Override + public Client newRestEasyClient(Object customJacksonProvider, SSLContext sslContext, boolean disableTrustManager) { + // point here is to use default Quarkus providers rather than org.keycloak.admin.client.JacksonProvider + // as it doesn't work properly in native mode + return ClientBuilderWrapper.create(sslContext, disableTrustManager).build(); + } + }); + } }