随机出现的javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?

时间:2012-12-07 07:10:54

标签: java ssl https

在执行My java代码期间,我收到此错误消息

Exception in thread "main" AxisFault  faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:   faultString: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
faultActor:   faultNode:
faultDetail: 
{http://xml.apache.org/axis/}stackTrace: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?    at
com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:523) at
 com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:355) at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:830)   at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1170) at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1197)  at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1181)  at
org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186) at
org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)    at
org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)    at
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138) at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)    at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)     at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)   at
org.apache.axis.client.Call.invokeEngine(Call.java:2765)    at
org.apache.axis.client.Call.invoke(Call.java:2748)  at
org.apache.axis.client.Call.invoke(Call.java:2424)  at
org.apache.axis.client.Call.invoke(Call.java:2347)  at
org.apache.axis.client.Call.invoke(Call.java:1804)  at
crmondemand.ws.ecbs.customobject5.CustomObject5_BindingStub.customObject5Update(CustomObject5_BindingStub.java:301) at
crm.sapGUID.urlupdate(sapGUID.java:170)     at
 crm.sapGUID.readExcelFile(sapGUID.java:102)    at
 crm.sapGUID.main(sapGUID.java:218)

每次重新运行我的程序时,这个错误的出现都是随机的。有时是10分钟后,有时是8分钟后,1分钟后的总和时间,甚至是15分钟后的总和时间。

我支持代理并且在我的JAVA中使用与我的Internt Explorer中相同的代理设置硬编码

System.setProperty("https.proxyHost", "172.*.*.*");
System.setProperty("https.proxyPort", "8003");
System.setProperty("javax.net.ssl.trustStore", "/Oracle/Middleware/wlserver_10.3/server/lib/cacerts");

3 个答案:

答案 0 :(得分:1)

我认为这是因为您正在使用System.setProperty() ...如果同一JVM中的其他内容正在调用相同的System.setProperty(),它将覆盖您的设置。你最好的拍摄是使用:

InetSocketAddress proxyInet = new InetSocketAddress("172...*",8003);
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyInet);

javax.net.ssl.trustStore可能没问题,因为它从命令行传入-D选项并且很少更改,因此,我认为您不需要在代码中设置它。至少如果你需要它,可以在static {}块中设置它,这样它只会加载一个,不需要重复设置。

答案 1 :(得分:1)

除非您始终使用相同的URL运行此操作,否则您正在执行异常中所述的操作:使用SSL连接到纯文本端口。偶尔。

答案 2 :(得分:0)

设置环境变量

{{1}}

这解决了我的问题。如果你在公司的私人网络上,试一试。