Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3439

log4j2 Spring Cloud config integration with MTLS gives NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.18.0
    • None
    • None

    Description

      Hello

       

      I am trying to use the log4j2 Spring cloud config integration capabilities and have been referring to the sample application on the github project https://github.com/apache/logging-log4j2/tree/release-2.x/log4j-spring-cloud-config/log4j-spring-cloud-config-samples When I try to configure a MTLS HTTPs URL of my cloud config server in the bootstrap.yaml of my client application which needs to fetch the log4j2.xml, I get a NPE in the 

      org.apache.logging.log4j.core.net.ssl.SslConfiguration.createSslContext(

      final boolean loadDefaultKeyManagerFactory, final boolean loadDefaultTrustManagerFactory) method when the SSLContext.getInstance(this.protocol); is invoked. On debugging I see that the protocol being passed from the SslConfigurationFactory to the SslConfiguration is "https" which causes SSLContext.getInstance() to throw an exception and thus no sslContext is created. I have attached the stacktrace for your reference.

      Below is my configuration. Please let me know if I am missing something.

      logging:
      config: https://localhost:8888/common/default/${CONFIG_SERVER_LABEL_ESCAPED}/log4j2.xml

      log4j2:
      debug: true
      keyStoreLocation: file:///${HTTP_KEYSTORE_PATH}
      keyStoreType: JKS
      keyStorePassword: ${HTTP_KEYSTORE_PWD}
      trustStoreLocation: file:///${HTTP_TRUSTSTORE_PATH}
      trustStoreKeyStoreType: JKS
      trustStorePassword: ${HTTP_TRUSTSTORE_PWD}
      sslVerifyHostName: false

      Attachments

        1. log4j-core-stacktrace.txt
          33 kB
          Jayesh Netravali

        Issue Links

          Activity

            People

              pkarwasz Piotr Karwasz
              jayeshnetravali Jayesh Netravali
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: