use*_*061 3 ssl bouncycastle java-6
参考How to use TLS 1.2 in Java 6 中提供的解决方案,是否可以将 TSLSocketConnectionFactory 与 Apache HttpClient4.4 一起使用。
问候, j
小智 5
您应该能够将 TSLSocketConnectionFactory 与 HttpClient 一起使用,如下所示:
SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(new TLSSocketConnectionFactory(), new String[]{"TLSv1.2"}, null, new DefaultHostnameVerifier());
HttpClient client = HttpClientBuilder.create()
.setSSLSocketFactory(sf)
.build();
Run Code Online (Sandbox Code Playgroud)
您可能需要更改 TSLSocketConnectionFactory 中的某些 SSLSession 方法实现。
就我而言,当我尝试将它与 HttpClient 一起使用时,我必须更改以下内容:
在 SSLSocket() 实现中:
@Override
public String[] getEnabledCipherSuites() {
// return null;
return new String[]{""};
}
@Override
public String[] getEnabledProtocols() {
// return null;
return new String[]{""};
}
Run Code Online (Sandbox Code Playgroud)
在 SSLSession() 实现中:
@Override
public String getProtocol() {
// throw new UnsupportedOperationException();
return null;
}
@Override
public String getProtocol() {
// throw new UnsupportedOperationException();
return "";
}
@Override
public String getCipherSuite() {
// throw new UnsupportedOperationException();
return "":
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3033 次 |
| 最近记录: |