The issue is now fixed in the version 1.4.0 of Splunk, the code has been redesigned.
SSLv3 is disabled by default in Java 1.8 in favour of TLS but in the Splunk API the protocol SSLv3 is still enabled by default.
To use TLSv1.2, there is no longer need to modify the code in "com.splunk.HttpService".
As the code in this class has been modified, it offers a convenient way to override a method to use TLSv1.2 instead of the default SSLv3.
The method to override is "setSslSecurityProtocol()":
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2)
The sample code below illustrates the new way to override SSlv3 by TLSv1.2 (tested with Java 1.8.x and Splunk Java SDK 1.4.0):
import java.io.*;
import com.splunk.*;
public class SearchExport {
public static void main(String[] args) throws IOException {
if(args.length != 4) {
System.out.println("Usage:\n\tjava SplunkConnect <username> <password> <hostname> <port>");
System.out.println("\tE.G. java SplunkConnect admin P@55w0rd 127.0.0.1 8089\n");
System.exit(1);
}
/* Overriding the static method setSslSecurityProtocol to implement the security protocol of choice */
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
/* end comment for overriding the method setSslSecurityProtocol */
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername(args[0]);
loginArgs.setPassword(args[1]);
loginArgs.setHost(args[2]);
loginArgs.setPort(new Integer(args[3]));
Service svc = Service.connect(loginArgs);
JobExportArgs exportArgs = new JobExportArgs();
exportArgs.setSearchMode(JobExportArgs.SearchMode.NORMAL);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a search string then press <ENTER>: ");
String mySearch = br.readLine();
if(!(mySearch.trim().startsWith("|")) && !(mySearch.substring(0, 6).equalsIgnoreCase("search"))) {
mySearch = "search " + mySearch;
}
InputStream exportSearch = svc.export(mySearch, exportArgs);
MultiResultsReaderXml resultsReader = new MultiResultsReaderXml(exportSearch);
long counter = 0;
for(SearchResults searchResults : resultsReader) {
for(Event event : searchResults) {
System.out.println("**** Event " + ++counter + " ****");
for(String key : event.keySet()) {
System.out.println("\t" + key + ": " + event.get(key));
}
}
}
resultsReader.close();
}
}
... View more