mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
8a19e12f92
commit
e054a80b16
@ -45,6 +45,7 @@ public class HttpGlobalConfig implements Serializable {
|
||||
* 是否从响应正文中的meta标签获取编码信息
|
||||
*/
|
||||
private static boolean getCharsetFromContent = true;
|
||||
private static boolean trustAnyHost = false;
|
||||
|
||||
/**
|
||||
* 获取全局默认的超时时长
|
||||
@ -211,4 +212,24 @@ public class HttpGlobalConfig implements Serializable {
|
||||
public static boolean isGetCharsetFromContent(){
|
||||
return getCharsetFromContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否信任所有Host
|
||||
* @return 是否信任所有Host
|
||||
* @since 5.8.27
|
||||
*/
|
||||
public static boolean isTrustAnyHost(){
|
||||
return trustAnyHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否信任所有Host<br>
|
||||
* 见:https://github.com/dromara/hutool/issues/2042<br>
|
||||
*
|
||||
* @param customTrustAnyHost 如果设置为{@code false},则按照JDK默认验证机制,验证目标服务器的证书host和请求host是否一致,{@code true}表示不验证。
|
||||
* @since 5.8.27
|
||||
*/
|
||||
public static void setTrustAnyHost(boolean customTrustAnyHost) {
|
||||
trustAnyHost = customTrustAnyHost;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class ClientConfig {
|
||||
public ClientConfig() {
|
||||
connectionTimeout = HttpGlobalConfig.getTimeout();
|
||||
readTimeout = HttpGlobalConfig.getTimeout();
|
||||
sslInfo = SSLInfo.TRUST_ANY;
|
||||
sslInfo = HttpGlobalConfig.isTrustAnyHost() ? SSLInfo.TRUST_ANY : SSLInfo.DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user