public class DefaultSslContextFactory extends SslContextFactory
SslContextFactory
makes it possible to configure most basic
options when building an SSLContext. See the init(Series)
method for
the list of parameters supported by this factory when configuring your HTTP
client or server connector. Here is the list of SSL related parameters that
are also supported:
Parameter name | Value type | Default value | Description |
---|---|---|---|
disabledCipherSuites | String | null | Whitespace-separated list of disabled cipher suites and/or can be specified multiple times. It affects the cipher suites manually enabled or the default ones. |
disabledProtocols | String (see Java Secure Socket Extension (JSSE) reference guide) | null | Whitespace-separated list of disabled SSL/TLS protocol names and/or can be specified multiple times. Used when creating SSL sockets and engines. |
enabledCipherSuites | String | null | Whitespace-separated list of enabled cipher suites and/or can be specified multiple times |
enabledProtocols | String (see Java Secure Socket Extension (JSSE) reference guide) | null | Whitespace-separated list of enabled SSL/TLS protocol names and/or can be specified multiple times. Used when creating SSL sockets and engines. |
keyManagerAlgorithm | String | System property "ssl.KeyManagerFactory.algorithm" or "SunX509" | Certificate algorithm for the key manager. |
keyStorePath | String | System property "javax.net.ssl.keyStore" or ${user.home}/.keystore | SSL keystore path. |
keyStorePassword | String | System property "javax.net.ssl.keyStorePassword" | SSL keystore password. |
keyStoreType | String | System property javax.net.ssl.keyStoreType or JKS | SSL keystore type |
keyPassword | String | System property "javax.net.ssl.keyStorePassword" | SSL key password. |
needClientAuthentication | boolean | false | Indicates if we require client certificate authentication. If set to 'true', the "wantClientAuthentication" parameter is ignored. |
protocol | String | TLS (see Java Secure Socket Extension (JSSE) reference guide) | SSL protocol used when creating the SSLContext. |
secureRandomAlgorithm | String | null (see java.security.SecureRandom) | Name of the RNG algorithm. (see java.security.SecureRandom class) |
trustManagerAlgorithm | String | System property "ssl.TrustManagerFactory.algorithm" or "SunX509" | Certificate algorithm for the trust manager. |
trustStorePassword | String | System property "javax.net.ssl.trustStorePassword" | Trust store password |
trustStorePath | String | System property "javax.net.ssl.trustStore" | Path to trust store |
trustStoreType | String | System property "javax.net.ssl.trustStoreType" | Trust store type |
wantClientAuthentication | boolean | false | Indicates if we would like client certificate authentication. Only taken into account if the "needClientAuthentication" parameter is 'false'. |
In short, two instances of KeyStore are used when configuring an SSLContext: the key store (which contains the public and private keys and certificates to be used locally) and the trust store (which generally holds the CA certificates to be trusted when connecting to a remote host). Both keystore and trust store are KeyStores. When not explicitly set using the setters of this class, the values will default to the default system properties, following the behavior described in the JSSE reference guide.
There is more information in the JSSE Reference Guide.
SSLContext
,
KeyStore
,
JSSE
Reference - Standard namesConstructor and Description |
---|
DefaultSslContextFactory() |
Modifier and Type | Method and Description |
---|---|
protected DefaultSslContextFactory |
clone()
This class is likely to contain sensitive information; cloning is
therefore not allowed.
|
javax.net.ssl.SSLContext |
createSslContext()
Creates a configured and initialized SSLContext from the values set via
the various setters of this class.
|
protected javax.net.ssl.SSLContext |
createWrapper(javax.net.ssl.SSLContext sslContext)
Creates a new
SSLContext wrapper. |
java.lang.String[] |
getDisabledCipherSuites()
Returns the whitespace-separated list of disabled cipher suites.
|
java.lang.String[] |
getDisabledProtocols()
Returns the whitespace-separated list of disabled SSL protocols.
|
java.lang.String[] |
getEnabledCipherSuites()
Returns the whitespace-separated list of enabled cipher suites.
|
java.lang.String[] |
getEnabledProtocols()
Returns the whitespace-separated list of enabled SSL protocols.
|
java.lang.String |
getKeyManagerAlgorithm()
Returns the name of the KeyManager algorithm.
|
char[] |
getKeyStoreKeyPassword()
Returns the password for the key in the keystore (as a String).
|
char[] |
getKeyStorePassword()
Returns the password for the keystore (as a String).
|
java.lang.String |
getKeyStorePath()
Returns the path to the KeyStore file.
|
java.lang.String |
getKeyStoreProvider()
Returns the name of the keystore provider.
|
java.lang.String |
getKeyStoreType()
Returns the keyStore type of the keystore.
|
java.lang.String |
getProtocol()
Returns the secure socket protocol name, "TLS" by default.
|
java.lang.String |
getSecureRandomAlgorithm()
Returns the name of the SecureRandom algorithm.
|
java.lang.String[] |
getSelectedCipherSuites(java.lang.String[] supportedCipherSuites)
Returns the selected cipher suites.
|
java.lang.String[] |
getSelectedSslProtocols(java.lang.String[] supportedProtocols)
Returns the selected SSL protocols.
|
java.lang.String |
getTrustManagerAlgorithm()
Returns the name of the TrustManager algorithm.
|
char[] |
getTrustStorePassword()
Returns the password for the trust store keystore.
|
java.lang.String |
getTrustStorePath()
Returns the path to the trust store (keystore) file.
|
java.lang.String |
getTrustStoreProvider()
Returns the name of the trust store (keystore) provider.
|
java.lang.String |
getTrustStoreType()
Returns the KeyStore type of the trust store.
|
void |
init(Series<Parameter> helperParameters)
Sets the following options according to parameters that may have been set
up directly in the HttpsClientHelper or HttpsServerHelper parameters.
|
boolean |
isNeedClientAuthentication()
Indicates if we require client certificate authentication.
|
boolean |
isWantClientAuthentication()
Indicates if we would like client certificate authentication.
|
void |
setDisabledCipherSuites(java.lang.String[] disabledCipherSuites)
Sets the whitespace-separated list of disabled cipher suites.
|
void |
setDisabledProtocols(java.lang.String[] disabledProtocols)
Sets the whitespace-separated list of disabled SSL protocols.
|
void |
setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
Sets the whitespace-separated list of enabled cipher suites.
|
void |
setEnabledProtocols(java.lang.String[] enabledProtocols)
Sets the standard name of the protocols to use when creating the SSL
sockets or engines.
|
void |
setKeyManagerAlgorithm(java.lang.String keyManagerAlgorithm)
Sets the KeyManager algorithm.
|
void |
setKeyStoreKeyPassword(char[] keyStoreKeyPassword)
Sets the password of the key in the keystore.
|
void |
setKeyStoreKeyPassword(java.lang.String keyStoreKeyPassword)
Sets the password of the key in the keystore.
|
void |
setKeyStorePassword(char[] keyStorePassword)
Sets the keystore password.
|
void |
setKeyStorePassword(java.lang.String keyStorePassword)
Sets the keystore password.
|
void |
setKeyStorePath(java.lang.String keyStorePath)
Sets the path to the keystore file.
|
void |
setKeyStoreProvider(java.lang.String keyStoreProvider)
Sets the name of the keystore provider.
|
void |
setKeyStoreType(java.lang.String keyStoreType)
Sets the KeyStore type of the keystore.
|
void |
setNeedClientAuthentication(boolean needClientAuthentication)
Indicates if we require client certificate authentication.
|
void |
setProtocol(java.lang.String protocol)
Sets the secure socket protocol name, "TLS" by default.
|
void |
setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
Sets the SecureRandom algorithm.
|
void |
setTrustManagerAlgorithm(java.lang.String trustManagerAlgorithm)
Sets the TrustManager algorithm.
|
void |
setTrustStorePassword(char[] trustStorePassword)
Sets the password of the trust store KeyStore.
|
void |
setTrustStorePassword(java.lang.String trustStorePassword)
Sets the password of the trust store KeyStore.
|
void |
setTrustStorePath(java.lang.String trustStorePath)
Sets the path to the trust store KeyStore.
|
void |
setTrustStoreProvider(java.lang.String trustStoreProvider)
Sets the name of the trust store provider.
|
void |
setTrustStoreType(java.lang.String trustStoreType)
Sets the KeyStore type of the trust store.
|
void |
setWantClientAuthentication(boolean wantClientAuthentication)
Indicates if we would like client certificate authentication.
|
protected final DefaultSslContextFactory clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public javax.net.ssl.SSLContext createSslContext() throws java.lang.Exception
keyStorePath
,
keyStoreProvider
, keyStoreType
are all
null
, the SSLContext will be initialized with a
null array of KeyManager
s. Similarly, if
trustStorePath
, trustStoreProvider
,
trustStoreType
are all null
, a
null
array of TrustManager
s will be used.
createSslContext
in class SslContextFactory
java.lang.Exception
SSLContext.init(javax.net.ssl.KeyManager[],
javax.net.ssl.TrustManager[], SecureRandom)
protected javax.net.ssl.SSLContext createWrapper(javax.net.ssl.SSLContext sslContext)
SSLContext
wrapper. Necessary to properly
initialize the SSLEngine
or SSLSocketFactory
or
SSLServerSocketFactory
created.sslContext
- The SSL context to wrap.public java.lang.String[] getDisabledCipherSuites()
public java.lang.String[] getDisabledProtocols()
public java.lang.String[] getEnabledCipherSuites()
public java.lang.String[] getEnabledProtocols()
public java.lang.String getKeyManagerAlgorithm()
public char[] getKeyStoreKeyPassword()
public char[] getKeyStorePassword()
public java.lang.String getKeyStorePath()
public java.lang.String getKeyStoreProvider()
public java.lang.String getKeyStoreType()
public java.lang.String getProtocol()
public java.lang.String getSecureRandomAlgorithm()
public java.lang.String[] getSelectedCipherSuites(java.lang.String[] supportedCipherSuites)
supportedCipherSuites
- The initial cipher suites to restrict.public java.lang.String[] getSelectedSslProtocols(java.lang.String[] supportedProtocols)
getEnabledProtocols()
name.supportedProtocols
- The selected SSL protocols.public java.lang.String getTrustManagerAlgorithm()
public char[] getTrustStorePassword()
public java.lang.String getTrustStorePath()
public java.lang.String getTrustStoreProvider()
public java.lang.String getTrustStoreType()
public void init(Series<Parameter> helperParameters)
init
in class SslContextFactory
helperParameters
- Typically, the parameters that would have been obtained from
HttpsServerHelper.getParameters()public boolean isNeedClientAuthentication()
public boolean isWantClientAuthentication()
public void setDisabledCipherSuites(java.lang.String[] disabledCipherSuites)
disabledCipherSuites
- The whitespace-separated list of disabled cipher suites.public void setDisabledProtocols(java.lang.String[] disabledProtocols)
disabledProtocols
- The whitespace-separated list of disabled SSL protocols.public void setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
enabledCipherSuites
- The whitespace-separated list of enabled cipher suites.public void setEnabledProtocols(java.lang.String[] enabledProtocols)
enabledProtocols
- The standard name of the protocols to use when creating the
SSL sockets or engines.public void setKeyManagerAlgorithm(java.lang.String keyManagerAlgorithm)
keyManagerAlgorithm
- The KeyManager algorithm.public void setKeyStoreKeyPassword(char[] keyStoreKeyPassword)
keyStoreKeyPassword
- The password of the key in the keystore.public void setKeyStoreKeyPassword(java.lang.String keyStoreKeyPassword)
keyStoreKeyPassword
- The password of the key in the keystore.public void setKeyStorePassword(char[] keyStorePassword)
keyStorePassword
- Sets the keystore password.public void setKeyStorePassword(java.lang.String keyStorePassword)
keyStorePassword
- Sets the keystore password.public void setKeyStorePath(java.lang.String keyStorePath)
keyStorePath
- The path to the keystore file.public void setKeyStoreProvider(java.lang.String keyStoreProvider)
keyStoreProvider
- The name of the keystore provider.public void setKeyStoreType(java.lang.String keyStoreType)
keyStoreType
- The KeyStore type of the keystore.public void setNeedClientAuthentication(boolean needClientAuthentication)
needClientAuthentication
- True if we require client certificate authentication.public void setProtocol(java.lang.String protocol)
protocol
- Name of the secure socket protocol to use.public void setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
secureRandomAlgorithm
- The SecureRandom algorithm.public void setTrustManagerAlgorithm(java.lang.String trustManagerAlgorithm)
trustManagerAlgorithm
- The TrustManager algorithm.public void setTrustStorePassword(char[] trustStorePassword)
trustStorePassword
- The password of the trust store KeyStore.public void setTrustStorePassword(java.lang.String trustStorePassword)
trustStorePassword
- The password of the trust store KeyStore.public void setTrustStorePath(java.lang.String trustStorePath)
trustStorePath
- The trustStorePath to setpublic void setTrustStoreProvider(java.lang.String trustStoreProvider)
trustStoreProvider
- The name of the trust store provider.public void setTrustStoreType(java.lang.String trustStoreType)
trustStoreType
- The KeyStore type of the trust store.public void setWantClientAuthentication(boolean wantClientAuthentication)
wantClientAuthentication
- True if we would like client certificate authentication.Copyright © 2005-2024 Restlet.