This commit is contained in:
Looly 2024-08-13 15:22:26 +08:00
parent 7882b3b485
commit a38d7b47ab
2 changed files with 18 additions and 4 deletions

View File

@ -35,8 +35,8 @@ import java.security.SecureRandom;
* <ul>
* <li>协议protocol默认TLS</li>
* <li>{@link KeyManager}默认空</li>
* <li>{@link TrustManager}默认{@link TrustAnyTrustManager}即信任全部</li>
* <li>{@link SecureRandom}</li>
* <li>{@link TrustManager}默认{@code null}</li>
* <li>{@link SecureRandom}默认{@code null}</li>
* </ul>
* <p>
* 构建后可获得{@link SSLContext}通过调用{@link SSLContext#getSocketFactory()}获取{@link javax.net.ssl.SSLSocketFactory}
@ -49,8 +49,8 @@ public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
private String protocol = TLS;
private KeyManager[] keyManagers;
private TrustManager[] trustManagers = TrustManagerUtil.TRUST_ANYS;
private SecureRandom secureRandom = new SecureRandom();
private TrustManager[] trustManagers;
private SecureRandom secureRandom;
/**

View File

@ -0,0 +1,14 @@
package org.dromara.hutool.core.net.ssl;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import javax.net.ssl.SSLContext;
public class SSLContextUtilTest {
@Test
void createTrustAnySSLContextTest() {
final SSLContext trustAnySSLContext = SSLContextUtil.createTrustAnySSLContext();
Assertions.assertNotNull(trustAnySSLContext);
}
}