shashank created CAMEL-25287:
--------------------------------

             Summary: camel-splunk-hec - the producer fails to start with 
"NullPointerException: SSL context" when no sslContextParameters is configured
                 Key: CAMEL-25287
                 URL: https://issues.apache.org/jira/browse/CAMEL-25287
             Project: Camel
          Issue Type: Bug
          Components: camel-splunk-hec
            Reporter: shashank


Since sslContextParameters was added (CAMEL-20393, PR #14998, Camel 4.8), 
{{SplunkHECProducer.doStart}} builds the HTTPS socket factory from the SSL 
context of the endpoint:

{code:java}
} else {
    SSLConnectionSocketFactory sslsf
            = new SSLConnectionSocketFactory(endpoint.provideSSLContext());
{code}

{{SplunkHECEndpoint.provideSSLContext()}} returns {{null}} when neither the 
endpoint nor the component has {{sslContextParameters}}, which is the default. 
HttpClient 5 rejects a null SSL context ({{Args.notNull(sslContext, "SSL 
context")}}), so the producer does not start:

{noformat}
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for 
endpoint: splunk-hec://localhost:8088?token=xxxxxx.
Reason: java.lang.NullPointerException: SSL context
    at 
org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.<init>(SSLConnectionSocketFactory.java:148)
    at org.apache.camel.component.splunkhec.SplunkHECProducer.doStart(...)
{noformat}

This happens for every endpoint without {{sslContextParameters}} and without 
{{skipTlsVerify=true}}, with {{https=true}} (the default) as well as with 
{{https=false}}. So a plain {{to("splunk-hec:splunk:8088?token=...")}} cannot 
send anything. The existing unit tests replace the HTTP client by a mock and 
never start the producer; the IT is a manual test.

h3. Reproduction

{{SplunkHECProducerHttpTest}} (new, a JDK {{HttpServer}} as HEC endpoint):
* {{testStartWithoutSslContextParameters}}: a producer for 
{{splunk-hec:localhost:8088?token=...}} must start. On main: {{Unexpected 
exception thrown: java.lang.NullPointerException: SSL context}}.
* {{testSendOverHttp}}: {{https=false}}, the event must reach the server. On 
main: {{FailedToCreateProducerException ... NullPointerException: SSL context}}.
* {{testSendOverHttpWithSslContextParameters}}: control, the same with 
{{sslContextParameters}} configured, passes on main.

h3. Proposed fix

Without an SSL context from {{sslContextParameters}}, use 
{{SSLConnectionSocketFactory.getSocketFactory()}}: HttpClient's default TLS 
set-up ({{SSLContexts.createDefault()}}: the JVM default trust store, 
{{cacerts}} or {{javax.net.ssl.trustStore}}, and the default hostname verifier, 
as CAMEL-23505 intended). This is what the producer used before 4.8, when it 
built the default {{PoolingHttpClientConnectionManager}}, and what CAMEL-20393 
describes as the way to connect without {{sslContextParameters}} (certificates 
at JRE level). Certificate and hostname verification stay on; only 
{{skipTlsVerify=true}} turns them off, as before. With the fix the 3 tests 
pass, and the module suite passes (33 tests, 2 skipped manual ITs).

Not in scope: the component option {{useGlobalSslContextParameters}} is not 
applied ({{retrieveGlobalSslContextParameters()}} is never called), a separate 
issue.

Affected: 4.14.x, 4.18.x and main (same code; 4.8 and later).

Duplicate check (2026-10-03): JIRA text "splunk-hec" / "splunkhec" (17 issues: 
CAMEL-23784, 23505, 23295, 20393, ...): none about the producer failing to 
start without SSL parameters. GitHub pull requests "splunk": none open.

_Filed with Claude Code on behalf of allthingssecurity._




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to