Uploaded image for project: 'Red Hat build of Keycloak'
  1. Red Hat build of Keycloak
  2. RHBK-2322

KC_CACHE_EMBEDDED_MTLS_ENABLED is ignored [GHI#34644]

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Before reporting an issue

      [X] I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

      Area

      infinispan

      Describe the bug

      The environment variable KC_CACHE_EMBEDDED_MTLS_ENABLED is always evaluating to its default value, false.

      In the CacheManagerFactory class, the condition

      ```
      Configuration.isTrue(CachingOptions.CACHE_EMBEDDED_MTLS_ENABLED_PROPERTY)
      ```

      is always set to false.

      The problem is that the kc. header, known as NS_KEYCLOAK_PREFIX, isn't being added to the string when being evaluated. A workaround for this problem is to use CACHE_EMBEDDED_MTLS_ENABLED, without the KC_ prefix.

      To fix this, there are two potential solutions.

      1. Add the NS_KEYCLOAK_PREFIX to the Configuration.isTrue(String) method.
      Change
      ```
      public static boolean isTrue(String propertyName)

      { {code}
      return getOptionalBooleanValue(propertyName).orElse(false);
      }
      
      

      ```
      to
      ```
      public static boolean isTrue(String propertyName) {{code}

      return getOptionalBooleanValue(NS_KEYCLOAK_PREFIX + propertyName).orElse(false);
      }

      ```
      
      2. Use Configuration.isTrue(Option<Boolean>) instead in {{CacheManagerFactory}}.
      Change 
      ```
      if (Configuration.isTrue(CachingOptions.CACHE_EMBEDDED_MTLS_ENABLED_PROPERTY)) {
      

      ...
      }

      ```
      to
      ```
      if (Configuration.isTrue(CachingOptions.CACHE_EMBEDDED_MTLS_ENABLED)) {
      

      ...
      }

      
      

      ```

      Version

      26.0.0

      Regression

      [ ] The issue is a regression

      Expected behavior

      By setting KC_CACHE_EMBEDDED_MTLS_ENABLED to true, the log message MTLS enabled for communications for embedded caches should appear

      Actual behavior

      Since it's always defaulting to false, the log message doesn't appear and TLS doesn't get properly set up.

      How to Reproduce?

      Set the environment variable KC_CACHE_EMBEDDED_MTLS_ENABLED to true, and the MTLS enabled logging message will not appear.

      Anything else?

              Unassigned Unassigned
              pvlha Pavel Vlha
              Keycloak SRE
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: