运行Splunk SDK示例时出错:“没有适当的协议(禁用协议或密码套件不合适)”

时间:2016-06-24 18:41:16

标签: java c# splunk

我从网站(http://dev.splunk.com/sdks)下载了Splunk Java SDK,并尝试在jdk1.8.0_91(Windows 10)下运行它。 但是我得到例外。我如何使它工作?

"C:\Program Files\Java\jdk1.8.0_91\bin\java" -Didea.launcher.port=7537 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_91\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\rt.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\out\production\examples;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\out\production\splunk;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\gson-2.2.4.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\opencsv-2.3.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-explorer.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-util.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-nodes.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-util-lookup.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-awt.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-dialogs.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-actions.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\org-openide-filesystems.jar;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\out\production\util;C:\Users\vitalii\Downloads\splunk-sdk-java-1.5.0\lib\commons-cli-1.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.1.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.splunk.examples.search.Program "index=alpo-dev 12345"
java.lang.RuntimeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
    at com.splunk.HttpService.send(HttpService.java:409)
    at com.splunk.Service.send(Service.java:1293)
    at com.splunk.HttpService.post(HttpService.java:308)
    at com.splunk.Service.login(Service.java:1122)
    at com.splunk.Service.login(Service.java:1101)
    at com.splunk.Service.connect(Service.java:187)
    at com.splunk.examples.search.Program.run(Program.java:117)
    at com.splunk.examples.search.Program.main(Program.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
    at sun.security.ssl.Handshaker.activate(Handshaker.java:503)
    at sun.security.ssl.SSLSocketImpl.kickstartHandshake(SSLSocketImpl.java:1482)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1351)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
    at com.splunk.HttpService.send(HttpService.java:403)
    ... 12 more

Process finished with exit code 1

Actuall我首先尝试了C#SDK,但我得到了异常"The request was aborted: Could not create SSL/TLS secure channel"

示例应用程序的代码位于:https://github.com/splunk/splunk-sdk-java/blob/master/examples/com/splunk/examples/search/Program.java

3 个答案:

答案 0 :(得分:5)

您也可以通过覆盖此类SSL安全协议来解决此问题。

HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

此处有更多详情 - https://answers.splunk.com/answers/209379/no-appropriate-protocol-protocol-is-disabled-or-ci.html

答案 1 :(得分:4)

我能够通过评论文件C:\Program Files\Java\jdk1.8.0_91\jre\lib\security\java.security中的行来解决这个问题:

# jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768

答案 2 :(得分:0)

由于Java SSL和Splunk SSL配置之间不兼容而引发此异常。 Java 8默认不支持SSLV3,但是Splunk支持SSLV3。

解决方案是:

a)在Splunk中更改HttpService类 b)在java.security软件包中注释SSL配置行。 c)覆盖HttpService类的方法以使用SSLv2版本。

有关更多详细信息,请查看下面的给定链接。 https://answers.splunk.com/answers/209379/no-appropriate-protocol-protocol-is-disabled-or-ci.html