mirror of
https://gitee.com/dromara/hutool.git
synced 2025-07-17 01:46:22 +08:00
fix #3582
This commit is contained in:
parent
73764db818
commit
cf44ae005a
@ -12,11 +12,13 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.net.ssl;
|
package org.dromara.hutool.core.net.ssl;
|
||||||
|
|
||||||
|
import org.dromara.hutool.core.exception.HutoolException;
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
import org.dromara.hutool.core.io.IORuntimeException;
|
||||||
|
|
||||||
import javax.net.ssl.KeyManager;
|
import javax.net.ssl.KeyManager;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSL(Secure Sockets Layer 安全套接字协议)中的{@link SSLContext}相关工具封装
|
* SSL(Secure Sockets Layer 安全套接字协议)中的{@link SSLContext}相关工具封装
|
||||||
@ -26,6 +28,20 @@ import javax.net.ssl.TrustManager;
|
|||||||
*/
|
*/
|
||||||
public class SSLContextUtil {
|
public class SSLContextUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取默认的{@link SSLContext}
|
||||||
|
*
|
||||||
|
* @return {@link SSLContext}
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
public static SSLContext getDefault() {
|
||||||
|
try {
|
||||||
|
return SSLContext.getDefault();
|
||||||
|
} catch (final NoSuchAlgorithmException e) {
|
||||||
|
throw new HutoolException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建{@link SSLContext},信任全部,协议为TLS
|
* 创建{@link SSLContext},信任全部,协议为TLS
|
||||||
*
|
*
|
||||||
|
@ -229,7 +229,7 @@ public class HttpGlobalConfig implements Serializable {
|
|||||||
* @param customTrustAnyHost 如果设置为{@code false},则按照JDK默认验证机制,验证目标服务器的证书host和请求host是否一致,{@code true}表示不验证。
|
* @param customTrustAnyHost 如果设置为{@code false},则按照JDK默认验证机制,验证目标服务器的证书host和请求host是否一致,{@code true}表示不验证。
|
||||||
* @since 5.8.27
|
* @since 5.8.27
|
||||||
*/
|
*/
|
||||||
public static void setTrustAnyHost(boolean customTrustAnyHost) {
|
public static void setTrustAnyHost(final boolean customTrustAnyHost) {
|
||||||
trustAnyHost = customTrustAnyHost;
|
trustAnyHost = customTrustAnyHost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,9 @@ public class SSLInfo {
|
|||||||
/**
|
/**
|
||||||
* 默认{@code SSLInfo},全部为{@code null},使用客户端引擎默认配置
|
* 默认{@code SSLInfo},全部为{@code null},使用客户端引擎默认配置
|
||||||
*/
|
*/
|
||||||
public static final SSLInfo DEFAULT = SSLInfo.of();
|
public static final SSLInfo DEFAULT = SSLInfo.of()
|
||||||
|
// issue#3582
|
||||||
|
.setSslContext(SSLContextUtil.getDefault());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信任所有的{@code SSLInfo}
|
* 信任所有的{@code SSLInfo}
|
||||||
|
Loading…
Reference in New Issue
Block a user