mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 #3655 通过支持现代 TLS 版本修复 SSL 握手失败问题
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
This commit is contained in:
@@ -53,4 +53,10 @@ public interface ApacheHttpClientBuilder {
|
||||
* ssl连接socket工厂.
|
||||
*/
|
||||
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory);
|
||||
|
||||
/**
|
||||
* 支持的TLS协议版本.
|
||||
* Supported TLS protocol versions.
|
||||
*/
|
||||
ApacheHttpClientBuilder supportedProtocols(String[] supportedProtocols);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,13 @@ public class ApacheHttpDnsClientBuilder implements ApacheHttpClientBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApacheHttpClientBuilder supportedProtocols(String[] supportedProtocols) {
|
||||
// This implementation doesn't use the supportedProtocols parameter as it relies on the provided SSLConnectionSocketFactory
|
||||
// Users should configure the SSLConnectionSocketFactory with desired protocols before setting it
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取链接的超时时间设置,默认3000ms
|
||||
* <p>
|
||||
|
||||
@@ -93,6 +93,12 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 支持的TLS协议版本,默认支持现代TLS版本
|
||||
* Supported TLS protocol versions, defaults to modern TLS versions
|
||||
*/
|
||||
private String[] supportedProtocols = {"TLSv1.2", "TLSv1.3", "TLSv1.1", "TLSv1"};
|
||||
|
||||
/**
|
||||
* 自定义请求拦截器
|
||||
*/
|
||||
@@ -179,6 +185,12 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApacheHttpClientBuilder supportedProtocols(String[] supportedProtocols) {
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IdleConnectionMonitorThread getIdleConnectionMonitorThread() {
|
||||
return this.idleConnectionMonitorThread;
|
||||
}
|
||||
@@ -257,7 +269,7 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
|
||||
|
||||
return new SSLConnectionSocketFactory(
|
||||
sslcontext,
|
||||
new String[]{"TLSv1"},
|
||||
this.supportedProtocols,
|
||||
null,
|
||||
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
|
||||
|
||||
Reference in New Issue
Block a user