Class TrustAllManager
java.lang.Object
cloud.opencode.base.crypto.ssl.TrustAllManager
- All Implemented Interfaces:
TrustManager, X509TrustManager
Trust All Manager - X509TrustManager that Trusts All Certificates
信任所有管理器 - 信任所有证书的 X509TrustManager
WARNING: This trust manager accepts ALL certificates without validation. Use ONLY for development and testing purposes.
警告:此信任管理器接受所有证书而不进行验证。 仅用于开发和测试目的。
Example | 示例:
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{TrustAllManager.INSTANCE}, null);
Features | 主要功能:
- Trusts all certificates without validation - 不验证地信任所有证书
- Development and testing only - 仅用于开发和测试
Usage Examples | 使用示例:
// Development only
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(null, new TrustManager[]{TrustAllManager.INSTANCE}, null);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial - 空值安全: 部分
- Since:
- JDK 25, opencode-base-crypto V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TrustAllManagerSingleton instance.static final StringSystem property to enable TrustAllManager in production (NOT recommended) 在生产环境启用TrustAllManager的系统属性(不推荐) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckClientTrusted(X509Certificate[] chain, String authType) Does not check client certificates.voidcheckServerTrusted(X509Certificate[] chain, String authType) Does not check server certificates.static TrustAllManagercreateUnsafe(boolean acknowledgeSecurityRisk) Creates a new instance with explicit acknowledgment of security risks.Returns empty accepted issuers.
-
Field Details
-
TRUST_ALL_ENABLED_PROPERTY
System property to enable TrustAllManager in production (NOT recommended) 在生产环境启用TrustAllManager的系统属性(不推荐)- See Also:
-
INSTANCE
Singleton instance. 单例实例。
-
-
Method Details
-
createUnsafe
Creates a new instance with explicit acknowledgment of security risks. 创建一个明确承认安全风险的新实例。- Parameters:
acknowledgeSecurityRisk- must be true to create instance | 必须为true才能创建实例- Returns:
- new TrustAllManager instance | 新的TrustAllManager实例
- Throws:
SecurityException- if acknowledgeSecurityRisk is false | 如果acknowledgeSecurityRisk为false则抛出
-
checkClientTrusted
Does not check client certificates. 不检查客户端证书。- Specified by:
checkClientTrustedin interfaceX509TrustManager- Parameters:
chain- the certificate chain - 证书链authType- the authentication type - 认证类型
-
checkServerTrusted
Does not check server certificates. 不检查服务器证书。- Specified by:
checkServerTrustedin interfaceX509TrustManager- Parameters:
chain- the certificate chain - 证书链authType- the authentication type - 认证类型
-
getAcceptedIssuers
Returns empty accepted issuers. 返回空的接受的签发者。- Specified by:
getAcceptedIssuersin interfaceX509TrustManager- Returns:
- empty array - 空数组
-