public class SSLContextBuilder extends Object implements SSLProtocols, Builder<SSLContext>
SSLContext构建器,可以自定义:KeyManager,默认空TrustManager,默认DefaultTrustManager,即信任全部SecureRandom
构建后可获得SSLContext,通过调用SSLContext.getSocketFactory()获取SSLSocketFactory
| Constructor and Description |
|---|
SSLContextBuilder() |
| Modifier and Type | Method and Description |
|---|---|
SSLContext |
build()
|
SSLContext |
buildChecked()
构建
SSLContext需要处理异常 |
SSLContext |
buildQuietly()
|
static SSLContextBuilder |
create()
创建 SSLContextBuilder
|
SSLContextBuilder |
setKeyManagers(KeyManager... keyManagers)
设置 JSSE key managers
|
SSLContextBuilder |
setProtocol(String protocol)
设置协议。
|
SSLContextBuilder |
setSecureRandom(SecureRandom secureRandom)
设置 SecureRandom
|
SSLContextBuilder |
setTrustManagers(TrustManager... trustManagers)
设置信任信息
|
public static SSLContextBuilder create()
public SSLContextBuilder setProtocol(String protocol)
protocol - 协议public SSLContextBuilder setTrustManagers(TrustManager... trustManagers)
trustManagers - TrustManager列表public SSLContextBuilder setKeyManagers(KeyManager... keyManagers)
keyManagers - JSSE key managerspublic SSLContextBuilder setSecureRandom(SecureRandom secureRandom)
secureRandom - SecureRandompublic SSLContext build()
build in interface Builder<SSLContext>SSLContextpublic SSLContext buildChecked() throws NoSuchAlgorithmException, KeyManagementException
SSLContext需要处理异常SSLContextNoSuchAlgorithmException - 无此算法异常KeyManagementException - 密钥管理异常public SSLContext buildQuietly() throws IORuntimeException
SSLContextIORuntimeException - 包装 GeneralSecurityException异常Copyright © 2025. All rights reserved.