Getting Data In

Why am I getting error "Unrecognized SSL message, plaintext connection?" trying to connect to Splunk with the Java REST API?

monanimihir
Explorer

I am trying to connect with Splunk. It is accessible from the web browser, but not with Java REST API.

           connectionArgs.put("host", "splunk-ui");
    connectionArgs.put("username", "username");
    connectionArgs.put("password", "passwd");
    connectionArgs.put("port", 8443);
    connectionArgs.put("scheme", "http");

    Service splunkService = Service.connect(connectionArgs);
    System.out.println("Auth Token : " + splunkService.getToken());

This is the error:

"Unrecognized SSL message, plaintext connection?" at line 'Service splunkService = Service.connect(connectionArgs);'

I am not able to understand the error.

0 Karma

monanimihir
Explorer

Host name was wrong, Thanks for help guys.

0 Karma

Damien_Dallimor
Ultra Champion

Unless you have changed your system default settings you should be connecting to port 8089 over https to access the Splunk REST endpoints.

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Port 8443 is typically reserved for HTTPS connections, yet you defined your scheme as http.

Change it like this and try again:

 connectionArgs.put("scheme","https");

I'm sure you will also have to do some Java-nasty overrides for the SSL cert to get it to accept the default certificates.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...