我可以在每个连接的基础上设置https.protocols jvm属性而不是全局吗?

时间:2016-10-27 21:01:51

标签: java properties tls1.2 tls1.1

有没有办法在每个连接的基础上而不是整个JVM上做这样的事情?

bundle exec rake time:zones:all

我收到这样的错误,另一篇文章将上述内容显示为解决方案:

System.setProperty("https.protocols", "TLSv1");

我不希望它适用于通过JVM运行的所有内容,只需要在一个类中的单个方法中进行一次特定调用。

这可能吗?

我正在使用Java在Apache Commons中使用v3.0.1 HttpClient建立与Web服务的连接 - 做这样的事情:

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
    at com.pilotfish.eip.modules.http.HttpPostTransport$2.run(HttpPostTransport.java:233)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(Unknown Source)
    ... 15 more

0 个答案:

没有答案