Splunk Dev

Java 访问splunk服务器出现错误:java.lang.RuntimeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

yizezhong
New Member
import java.io.*;

import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

import com.splunk.Application;
import com.splunk.Service;
import com.splunk.ServiceArgs;

public class SplunkLinkDemo {


/**
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {  

    // Create a map of arguments and add login parameters
    ServiceArgs loginArgs = new ServiceArgs();
    loginArgs.setUsername("admin");
    loginArgs.setPassword("123456");
    loginArgs.setHost("localhost");
    loginArgs.setPort(8089);
    //loginArgs.setScheme("https");
    // Create a Service instance and log in with the argument map
    Service service = Service.connect(loginArgs);

    // A second way to create a new Service object and log in
    // Service service = new Service("localhost", 8089);
    // service.login("admin", "changeme");

    // A third way to create a new Service object and log in
    // Service service = new Service(loginArgs);
    // service.login();

    // Print installed apps to the console to verify login
    /*for (Application app : service.getApplications().values()) {
        System.out.println(app.getName());
    }*/

}

}
Tags (3)
0 Karma

freebuf
New Member

public void splunk(){
try{
ServiceArgs login = new ServiceArgs();
login.setUsername("admin");
login.setPassword("1234");
login.setHost("localhost");
login.setPort(8089);
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
Service service = Service.connect(login);
for(User user : service.getUsers().values())
System.out.println(user.getName());
}catch(Exception e){
e.printStackTrace();
}

}
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...