public final class SslContextBuilder extends Object
SSLContext
instances for use when securing connections with SSL or
the StartTLS extended operation. The build()
should be
called in order to obtain the SSLContext
.
For example, use the SSL context builder when setting up LDAP options needed
to use StartTLS. TrustManagers
has methods you can use to set the trust manager for the SSL
context builder.
LDAPOptions options = new LDAPOptions(); SSLContext sslContext = new SSLContextBuilder().setTrustManager(...).getSSLContext(); options.setSSLContext(sslContext); options.setUseStartTLS(true); String host = ...; int port = ...; LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port, options); Connection connection = factory.getConnection(); // Connection uses StartTLS...
Modifier and Type | Field and Description |
---|---|
static String |
PROTOCOL_SSL
SSL protocol: supports some version of SSL; may support other versions.
|
static String |
PROTOCOL_SSL2
SSL protocol: supports SSL version 2 or higher; may support other versions.
|
static String |
PROTOCOL_SSL3
SSL protocol: supports SSL version 3; may support other versions.
|
static String |
PROTOCOL_TLS
SSL protocol: supports some version of TLS; may support other versions.
|
static String |
PROTOCOL_TLS1
SSL protocol: supports RFC 2246: TLS version 1.0 ; may support other versions.
|
static String |
PROTOCOL_TLS1_1
SSL protocol: supports RFC 4346: TLS version 1.1 ; may support other versions.
|
static String |
PROTOCOL_TLS1_2
SSL protocol: supports RFC 5246: TLS version 1.2 ; may support other versions.
|
Constructor and Description |
---|
SslContextBuilder()
Creates a new SSL context builder using default parameters.
|
Modifier and Type | Method and Description |
---|---|
SSLContext |
build()
Creates a
SSLContext using the parameters of this SSL context builder. |
SslContextBuilder |
keyManager(KeyManager keyManager)
Sets the key manager which the SSL context should use.
|
SslContextBuilder |
protocol(String protocol)
Sets the protocol which the SSL context should use.
|
SslContextBuilder |
provider(Provider provider)
Sets the provider which the SSL context should use.
|
SslContextBuilder |
provider(String providerName)
Sets the provider which the SSL context should use.
|
SslContextBuilder |
secureRandom(SecureRandom random)
Sets the secure random number generator which the SSL context should use.
|
SslContextBuilder |
trustManager(TrustManager trustManager)
Sets the trust manager which the SSL context should use.
|
public static final String PROTOCOL_SSL
public static final String PROTOCOL_SSL2
public static final String PROTOCOL_SSL3
public static final String PROTOCOL_TLS
public static final String PROTOCOL_TLS1
This is the default version.
public static final String PROTOCOL_TLS1_1
public static final String PROTOCOL_TLS1_2
public SslContextBuilder()
public SSLContext build() throws GeneralSecurityException
SSLContext
using the parameters of this SSL context builder.SSLContext
using the parameters of this SSL context builder.GeneralSecurityException
- If the SSL context could not be created, perhaps due to missing algorithms.public SslContextBuilder keyManager(KeyManager keyManager)
keyManager
- The key manager which the SSL context should use, which may be null
indicating that no
certificates will be used.public SslContextBuilder protocol(String protocol)
protocol
- The protocol which the SSL context should use, which may be
null
indicating that TLSv1 will be used.public SslContextBuilder provider(Provider provider)
provider
- The provider which the SSL context should use, which may be
null
indicating that the default provider associated
with this JVM will be used.public SslContextBuilder provider(String providerName)
providerName
- The name of the provider which the SSL context should use,
which may be null
indicating that the default provider
associated with this JVM will be used.public SslContextBuilder secureRandom(SecureRandom random)
random
- The secure random number generator which the SSL context
should use, which may be null
indicating that the
default secure random number generator associated with this
JVM will be used.public SslContextBuilder trustManager(TrustManager trustManager)
trustManager
- The trust manager which the SSL context should use, which may
be null
indicating that only certificates signed by
the authorities associated with this JVM will be accepted.Copyright 2010-2018 ForgeRock AS.