Class SslContextFactory
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.ssl.SslContextFactory
-
public class SslContextFactory extends AbstractLifeCycle implements Dumpable
SslContextFactory is used to configure SSL connectors as well as HttpClient. It holds all SSL parameters and creates SSL context based on these parameters to be used by the SSL connectors.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_KEYMANAGERFACTORY_ALGORITHM
static String
DEFAULT_TRUSTMANAGERFACTORY_ALGORITHM
static String
KEYPASSWORD_PROPERTY
String name of key password property.static String
PASSWORD_PROPERTY
String name of keystore password property.static TrustManager[]
TRUST_ALL_CERTS
-
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
-
-
Constructor Summary
Constructors Constructor Description SslContextFactory()
Construct an instance of SslContextFactory Default constructor for use in XmlConfiguration filesSslContextFactory(boolean trustAll)
Construct an instance of SslContextFactory Default constructor for use in XmlConfiguration filesSslContextFactory(String keyStorePath)
Construct an instance of SslContextFactory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addExcludeCipherSuites(String... cipher)
void
addExcludeProtocols(String... protocol)
void
customize(SSLEngine sslEngine)
Customize an SslEngine instance with the configuration of this factory, by callingcustomize(SSLParameters)
SSLParameters
customize(SSLParameters sslParams)
Customize an SslParameters instance with the configuration of this factory.static int
deduceKeyLength(String cipherSuite)
Given the name of a TLS/SSL cipher suite, return an int representing it effective stream cipher key strength.protected void
doStart()
Create the SSLContext object and starts the lifecycleprotected void
doStop()
String
dump()
void
dump(Appendable out, String indent)
Set<String>
getAliases()
String
getCertAlias()
static X509Certificate[]
getCertChain(SSLSession sslSession)
Comparator<String>
getCipherComparator()
String
getCrlPath()
String
getEndpointIdentificationAlgorithm()
String[]
getExcludeCipherSuites()
String[]
getExcludeProtocols()
String[]
getIncludeCipherSuites()
String[]
getIncludeProtocols()
String
getKeyManagerFactoryAlgorithm()
protected KeyManager[]
getKeyManagers(KeyStore keyStore)
KeyStore
getKeyStore()
String
getKeyStorePath()
String
getKeyStoreProvider()
Resource
getKeyStoreResource()
String
getKeyStoreType()
int
getMaxCertPathLength()
boolean
getNeedClientAuth()
String
getOcspResponderURL()
String
getProtocol()
String
getProvider()
int
getRenegotiationLimit()
String
getSecureRandomAlgorithm()
String[]
getSelectedCipherSuites()
String[]
getSelectedProtocols()
SSLContext
getSslContext()
String
getSslKeyManagerFactoryAlgorithm()
Deprecated.usegetKeyManagerFactoryAlgorithm()
insteadint
getSslSessionCacheSize()
Get SSL session cache size.int
getSslSessionTimeout()
Get SSL session timeout.String
getTrustManagerFactoryAlgorithm()
protected TrustManager[]
getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls)
KeyStore
getTrustStore()
String
getTrustStoreProvider()
Resource
getTrustStoreResource()
String
getTrustStoreType()
boolean
getWantClientAuth()
X509
getX509(String alias)
boolean
isEnableCRLDP()
boolean
isEnableOCSP()
boolean
isRenegotiationAllowed()
boolean
isSessionCachingEnabled()
boolean
isTrustAll()
boolean
isUseCipherSuitesOrder()
boolean
isValidateCerts()
boolean
isValidatePeerCerts()
protected Collection<? extends CRL>
loadCRL(String crlPath)
Loads certificate revocation list (CRL) from a file.protected KeyStore
loadKeyStore(Resource resource)
Override this method to provide alternate way to load a keystore.protected KeyStore
loadTrustStore(Resource resource)
Override this method to provide alternate way to load a truststore.SSLEngine
newSSLEngine()
Factory method for "scratch"SSLEngine
s, usually only used for retrieving configuration information such as the application buffer size or the list of protocols/ciphers.SSLEngine
newSSLEngine(String host, int port)
General purpose factory method for creatingSSLEngine
s, although creation ofSSLEngine
s on the server-side should prefernewSSLEngine(InetSocketAddress)
.SSLEngine
newSSLEngine(InetSocketAddress address)
Server-side only factory method for creatingSSLEngine
s.SSLServerSocket
newSslServerSocket(String host, int port, int backlog)
SSLSocket
newSslSocket()
protected void
processIncludeCipherSuites(String[] supportedCipherSuites, List<String> selected_ciphers)
void
reload(Consumer<SslContextFactory> consumer)
protected void
removeExcludedCipherSuites(List<String> selected_ciphers)
protected void
selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites)
Select cipher suites to be used by the connector based on configured inclusion and exclusion lists as well as enabled and supported cipher suite lists.void
selectProtocols(String[] enabledProtocols, String[] supportedProtocols)
Select protocols to be used by the connector based on configured inclusion and exclusion lists as well as enabled and supported protocols.void
setCertAlias(String certAlias)
Set the default certificate Alias.void
setCipherComparator(Comparator<String> cipherComparator)
void
setCrlPath(String crlPath)
void
setEnableCRLDP(boolean enableCRLDP)
Enables CRL Distribution Points Supportvoid
setEnableOCSP(boolean enableOCSP)
Enables On-Line Certificate Status Protocol supportvoid
setEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm)
When set to "HTTPS" hostname verification will be enabledvoid
setExcludeCipherSuites(String... cipherSuites)
You can either use the exact cipher suite name or a a regular expression.void
setExcludeProtocols(String... protocols)
void
setIncludeCipherSuites(String... cipherSuites)
You can either use the exact cipher suite name or a a regular expression.void
setIncludeProtocols(String... protocols)
void
setKeyManagerFactoryAlgorithm(String algorithm)
void
setKeyManagerPassword(String password)
void
setKeyStore(KeyStore keyStore)
Set the key store.void
setKeyStorePassword(String password)
void
setKeyStorePath(String keyStorePath)
void
setKeyStoreProvider(String keyStoreProvider)
void
setKeyStoreResource(Resource resource)
Set the key store resource.void
setKeyStoreType(String keyStoreType)
void
setMaxCertPathLength(int maxCertPathLength)
void
setNeedClientAuth(boolean needClientAuth)
void
setOcspResponderURL(String ocspResponderURL)
Set the location of the OCSP Responder.void
setProtocol(String protocol)
void
setProvider(String provider)
void
setRenegotiationAllowed(boolean renegotiationAllowed)
void
setRenegotiationLimit(int renegotiationLimit)
void
setSecureRandomAlgorithm(String algorithm)
void
setSessionCachingEnabled(boolean enableSessionCaching)
Set the flag to enable SSL Session caching.void
setSslContext(SSLContext sslContext)
void
setSslKeyManagerFactoryAlgorithm(String algorithm)
Deprecated.usesetKeyManagerFactoryAlgorithm(String)
insteadvoid
setSslSessionCacheSize(int sslSessionCacheSize)
Set SSL session cache size.void
setSslSessionTimeout(int sslSessionTimeout)
Set SSL session timeout.void
setTrustAll(boolean trustAll)
void
setTrustManagerFactoryAlgorithm(String algorithm)
void
setTrustStore(KeyStore trustStore)
Set the trust store.void
setTrustStorePassword(String password)
void
setTrustStorePath(String trustStorePath)
void
setTrustStoreProvider(String trustStoreProvider)
void
setTrustStoreResource(Resource resource)
Set the trust store resource.void
setTrustStoreType(String trustStoreType)
void
setUseCipherSuitesOrder(boolean useCipherSuitesOrder)
void
setValidateCerts(boolean validateCerts)
void
setValidatePeerCerts(boolean validatePeerCerts)
void
setWantClientAuth(boolean wantClientAuth)
String
toString()
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
-
-
-
Field Detail
-
TRUST_ALL_CERTS
public static final TrustManager[] TRUST_ALL_CERTS
-
DEFAULT_KEYMANAGERFACTORY_ALGORITHM
public static final String DEFAULT_KEYMANAGERFACTORY_ALGORITHM
-
DEFAULT_TRUSTMANAGERFACTORY_ALGORITHM
public static final String DEFAULT_TRUSTMANAGERFACTORY_ALGORITHM
-
KEYPASSWORD_PROPERTY
public static final String KEYPASSWORD_PROPERTY
String name of key password property.- See Also:
- Constant Field Values
-
PASSWORD_PROPERTY
public static final String PASSWORD_PROPERTY
String name of keystore password property.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SslContextFactory
public SslContextFactory()
Construct an instance of SslContextFactory Default constructor for use in XmlConfiguration files
-
SslContextFactory
public SslContextFactory(boolean trustAll)
Construct an instance of SslContextFactory Default constructor for use in XmlConfiguration files- Parameters:
trustAll
- whether to blindly trust all certificates- See Also:
setTrustAll(boolean)
-
SslContextFactory
public SslContextFactory(String keyStorePath)
Construct an instance of SslContextFactory- Parameters:
keyStorePath
- default keystore location
-
-
Method Detail
-
doStart
protected void doStart() throws Exception
Create the SSLContext object and starts the lifecycle- Overrides:
doStart
in classAbstractLifeCycle
- Throws:
Exception
-
dump
public void dump(Appendable out, String indent) throws IOException
- Specified by:
dump
in interfaceDumpable
- Throws:
IOException
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classAbstractLifeCycle
- Throws:
Exception
-
getSelectedProtocols
public String[] getSelectedProtocols()
-
getSelectedCipherSuites
public String[] getSelectedCipherSuites()
-
getCipherComparator
public Comparator<String> getCipherComparator()
-
setCipherComparator
public void setCipherComparator(Comparator<String> cipherComparator)
-
getExcludeProtocols
public String[] getExcludeProtocols()
- Returns:
- The array of protocol names to exclude from
SSLEngine.setEnabledProtocols(String[])
-
setExcludeProtocols
public void setExcludeProtocols(String... protocols)
- Parameters:
protocols
- The array of protocol names to exclude fromSSLEngine.setEnabledProtocols(String[])
-
addExcludeProtocols
public void addExcludeProtocols(String... protocol)
- Parameters:
protocol
- Protocol names to add toSSLEngine.setEnabledProtocols(String[])
-
getIncludeProtocols
public String[] getIncludeProtocols()
- Returns:
- The array of protocol names to include in
SSLEngine.setEnabledProtocols(String[])
-
setIncludeProtocols
public void setIncludeProtocols(String... protocols)
- Parameters:
protocols
- The array of protocol names to include inSSLEngine.setEnabledProtocols(String[])
-
getExcludeCipherSuites
public String[] getExcludeCipherSuites()
- Returns:
- The array of cipher suite names to exclude from
SSLEngine.setEnabledCipherSuites(String[])
-
setExcludeCipherSuites
public void setExcludeCipherSuites(String... cipherSuites)
You can either use the exact cipher suite name or a a regular expression.- Parameters:
cipherSuites
- The array of cipher suite names to exclude fromSSLEngine.setEnabledCipherSuites(String[])
-
addExcludeCipherSuites
public void addExcludeCipherSuites(String... cipher)
- Parameters:
cipher
- Cipher names to add toSSLEngine.setEnabledCipherSuites(String[])
-
getIncludeCipherSuites
public String[] getIncludeCipherSuites()
- Returns:
- The array of cipher suite names to include in
SSLEngine.setEnabledCipherSuites(String[])
-
setIncludeCipherSuites
public void setIncludeCipherSuites(String... cipherSuites)
You can either use the exact cipher suite name or a a regular expression.- Parameters:
cipherSuites
- The array of cipher suite names to include inSSLEngine.setEnabledCipherSuites(String[])
-
isUseCipherSuitesOrder
public boolean isUseCipherSuitesOrder()
-
setUseCipherSuitesOrder
public void setUseCipherSuitesOrder(boolean useCipherSuitesOrder)
-
getKeyStorePath
public String getKeyStorePath()
- Returns:
- The file or URL of the SSL Key store.
-
setKeyStorePath
public void setKeyStorePath(String keyStorePath)
- Parameters:
keyStorePath
- The file or URL of the SSL Key store.
-
getKeyStoreProvider
public String getKeyStoreProvider()
- Returns:
- The provider of the key store
-
setKeyStoreProvider
public void setKeyStoreProvider(String keyStoreProvider)
- Parameters:
keyStoreProvider
- The provider of the key store
-
getKeyStoreType
public String getKeyStoreType()
- Returns:
- The type of the key store (default "JKS")
-
setKeyStoreType
public void setKeyStoreType(String keyStoreType)
- Parameters:
keyStoreType
- The type of the key store (default "JKS")
-
getCertAlias
public String getCertAlias()
- Returns:
- Alias of SSL certificate for the connector
-
setCertAlias
public void setCertAlias(String certAlias)
Set the default certificate Alias.This can be used if there are multiple non-SNI certificates to specify the certificate that should be used, or with SNI certificates to set a certificate to try if no others match
- Parameters:
certAlias
- Alias of SSL certificate for the connector
-
setTrustStorePath
public void setTrustStorePath(String trustStorePath)
- Parameters:
trustStorePath
- The file name or URL of the trust store location
-
getTrustStoreProvider
public String getTrustStoreProvider()
- Returns:
- The provider of the trust store
-
setTrustStoreProvider
public void setTrustStoreProvider(String trustStoreProvider)
- Parameters:
trustStoreProvider
- The provider of the trust store
-
getTrustStoreType
public String getTrustStoreType()
- Returns:
- The type of the trust store (default "JKS")
-
setTrustStoreType
public void setTrustStoreType(String trustStoreType)
- Parameters:
trustStoreType
- The type of the trust store (default "JKS")
-
getNeedClientAuth
public boolean getNeedClientAuth()
- Returns:
- True if SSL needs client authentication.
- See Also:
SSLEngine.getNeedClientAuth()
-
setNeedClientAuth
public void setNeedClientAuth(boolean needClientAuth)
- Parameters:
needClientAuth
- True if SSL needs client authentication.- See Also:
SSLEngine.getNeedClientAuth()
-
getWantClientAuth
public boolean getWantClientAuth()
- Returns:
- True if SSL wants client authentication.
- See Also:
SSLEngine.getWantClientAuth()
-
setWantClientAuth
public void setWantClientAuth(boolean wantClientAuth)
- Parameters:
wantClientAuth
- True if SSL wants client authentication.- See Also:
SSLEngine.getWantClientAuth()
-
isValidateCerts
public boolean isValidateCerts()
- Returns:
- true if SSL certificate has to be validated
-
setValidateCerts
public void setValidateCerts(boolean validateCerts)
- Parameters:
validateCerts
- true if SSL certificates have to be validated
-
isValidatePeerCerts
public boolean isValidatePeerCerts()
- Returns:
- true if SSL certificates of the peer have to be validated
-
setValidatePeerCerts
public void setValidatePeerCerts(boolean validatePeerCerts)
- Parameters:
validatePeerCerts
- true if SSL certificates of the peer have to be validated
-
setKeyStorePassword
public void setKeyStorePassword(String password)
- Parameters:
password
- The password for the key store. If null is passed and a keystore is set, then thePassword.getPassword(String, String, String)
is used to obtain a password either from the "org.eclipse.jetty.ssl.password" System property or by prompting for manual entry.
-
setKeyManagerPassword
public void setKeyManagerPassword(String password)
- Parameters:
password
- The password (if any) for the specific key within the key store. If null is passed and the "org.eclipse.jetty.ssl.keypassword" system property is set, then thePassword.getPassword(String, String, String)
is used to obtain a password from the "org.eclipse.jetty.ssl.keypassword" system property.
-
setTrustStorePassword
public void setTrustStorePassword(String password)
- Parameters:
password
- The password for the trust store. If null is passed and a truststore is set that is different from the keystore, then thePassword.getPassword(String, String, String)
is used to obtain a password either from the "org.eclipse.jetty.ssl.password" System property or by prompting for manual entry.
-
getProvider
public String getProvider()
- Returns:
- The SSL provider name, which if set is passed to
SSLContext.getInstance(String, String)
-
setProvider
public void setProvider(String provider)
- Parameters:
provider
- The SSL provider name, which if set is passed toSSLContext.getInstance(String, String)
-
getProtocol
public String getProtocol()
- Returns:
- The SSL protocol (default "TLS") passed to
SSLContext.getInstance(String, String)
-
setProtocol
public void setProtocol(String protocol)
- Parameters:
protocol
- The SSL protocol (default "TLS") passed toSSLContext.getInstance(String, String)
-
getSecureRandomAlgorithm
public String getSecureRandomAlgorithm()
- Returns:
- The algorithm name, which if set is passed to
SecureRandom.getInstance(String)
to obtain theSecureRandom
instance passed toSSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], SecureRandom)
-
setSecureRandomAlgorithm
public void setSecureRandomAlgorithm(String algorithm)
- Parameters:
algorithm
- The algorithm name, which if set is passed toSecureRandom.getInstance(String)
to obtain theSecureRandom
instance passed toSSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], SecureRandom)
-
getSslKeyManagerFactoryAlgorithm
@Deprecated public String getSslKeyManagerFactoryAlgorithm()
Deprecated.usegetKeyManagerFactoryAlgorithm()
instead
-
setSslKeyManagerFactoryAlgorithm
@Deprecated public void setSslKeyManagerFactoryAlgorithm(String algorithm)
Deprecated.usesetKeyManagerFactoryAlgorithm(String)
instead
-
getKeyManagerFactoryAlgorithm
public String getKeyManagerFactoryAlgorithm()
- Returns:
- The algorithm name (default "SunX509") used by the
KeyManagerFactory
-
setKeyManagerFactoryAlgorithm
public void setKeyManagerFactoryAlgorithm(String algorithm)
- Parameters:
algorithm
- The algorithm name (default "SunX509") used by theKeyManagerFactory
-
getTrustManagerFactoryAlgorithm
public String getTrustManagerFactoryAlgorithm()
- Returns:
- The algorithm name (default "SunX509") used by the
TrustManagerFactory
-
isTrustAll
public boolean isTrustAll()
- Returns:
- True if all certificates should be trusted if there is no KeyStore or TrustStore
-
setTrustAll
public void setTrustAll(boolean trustAll)
- Parameters:
trustAll
- True if all certificates should be trusted if there is no KeyStore or TrustStore
-
setTrustManagerFactoryAlgorithm
public void setTrustManagerFactoryAlgorithm(String algorithm)
- Parameters:
algorithm
- The algorithm name (default "SunX509") used by theTrustManagerFactory
Use the string "TrustAll" to install a trust manager that trusts all.
-
isRenegotiationAllowed
public boolean isRenegotiationAllowed()
- Returns:
- whether TLS renegotiation is allowed (true by default)
-
setRenegotiationAllowed
public void setRenegotiationAllowed(boolean renegotiationAllowed)
- Parameters:
renegotiationAllowed
- whether TLS renegotiation is allowed
-
getRenegotiationLimit
public int getRenegotiationLimit()
- Returns:
- The number of renegotions allowed for this connection. When the limit is 0 renegotiation will be denied. If the limit is less than 0 then no limit is applied.
-
setRenegotiationLimit
public void setRenegotiationLimit(int renegotiationLimit)
- Parameters:
renegotiationLimit
- The number of renegotions allowed for this connection. When the limit is 0 renegotiation will be denied. If the limit is less than 0 then no limit is applied. Default 5.
-
getCrlPath
public String getCrlPath()
- Returns:
- Path to file that contains Certificate Revocation List
-
setCrlPath
public void setCrlPath(String crlPath)
- Parameters:
crlPath
- Path to file that contains Certificate Revocation List
-
getMaxCertPathLength
public int getMaxCertPathLength()
- Returns:
- Maximum number of intermediate certificates in the certification path (-1 for unlimited)
-
setMaxCertPathLength
public void setMaxCertPathLength(int maxCertPathLength)
- Parameters:
maxCertPathLength
- maximum number of intermediate certificates in the certification path (-1 for unlimited)
-
getSslContext
public SSLContext getSslContext()
- Returns:
- The SSLContext
-
setSslContext
public void setSslContext(SSLContext sslContext)
- Parameters:
sslContext
- Set a preconfigured SSLContext
-
getEndpointIdentificationAlgorithm
public String getEndpointIdentificationAlgorithm()
- Returns:
- the endpoint identification algorithm
-
setEndpointIdentificationAlgorithm
public void setEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm)
When set to "HTTPS" hostname verification will be enabled- Parameters:
endpointIdentificationAlgorithm
- Set the endpointIdentificationAlgorithm
-
loadKeyStore
protected KeyStore loadKeyStore(Resource resource) throws Exception
Override this method to provide alternate way to load a keystore.- Parameters:
resource
- the resource to load the keystore from- Returns:
- the key store instance
- Throws:
Exception
- if the keystore cannot be loaded
-
loadTrustStore
protected KeyStore loadTrustStore(Resource resource) throws Exception
Override this method to provide alternate way to load a truststore.- Parameters:
resource
- the resource to load the truststore from- Returns:
- the key store instance
- Throws:
Exception
- if the truststore cannot be loaded
-
loadCRL
protected Collection<? extends CRL> loadCRL(String crlPath) throws Exception
Loads certificate revocation list (CRL) from a file.Required for integrations to be able to override the mechanism used to load CRL in order to provide their own implementation.
- Parameters:
crlPath
- path of certificate revocation list file- Returns:
- Collection of CRL's
- Throws:
Exception
- if the certificate revocation list cannot be loaded
-
getKeyManagers
protected KeyManager[] getKeyManagers(KeyStore keyStore) throws Exception
- Throws:
Exception
-
getTrustManagers
protected TrustManager[] getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls) throws Exception
- Throws:
Exception
-
selectProtocols
public void selectProtocols(String[] enabledProtocols, String[] supportedProtocols)
Select protocols to be used by the connector based on configured inclusion and exclusion lists as well as enabled and supported protocols.- Parameters:
enabledProtocols
- Array of enabled protocolssupportedProtocols
- Array of supported protocols
-
selectCipherSuites
protected void selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites)
Select cipher suites to be used by the connector based on configured inclusion and exclusion lists as well as enabled and supported cipher suite lists.- Parameters:
enabledCipherSuites
- Array of enabled cipher suitessupportedCipherSuites
- Array of supported cipher suites
-
processIncludeCipherSuites
protected void processIncludeCipherSuites(String[] supportedCipherSuites, List<String> selected_ciphers)
-
removeExcludedCipherSuites
protected void removeExcludedCipherSuites(List<String> selected_ciphers)
-
isEnableCRLDP
public boolean isEnableCRLDP()
- Returns:
- true if CRL Distribution Points support is enabled
-
setEnableCRLDP
public void setEnableCRLDP(boolean enableCRLDP)
Enables CRL Distribution Points Support- Parameters:
enableCRLDP
- true - turn on, false - turns off
-
isEnableOCSP
public boolean isEnableOCSP()
- Returns:
- true if On-Line Certificate Status Protocol support is enabled
-
setEnableOCSP
public void setEnableOCSP(boolean enableOCSP)
Enables On-Line Certificate Status Protocol support- Parameters:
enableOCSP
- true - turn on, false - turn off
-
getOcspResponderURL
public String getOcspResponderURL()
- Returns:
- Location of the OCSP Responder
-
setOcspResponderURL
public void setOcspResponderURL(String ocspResponderURL)
Set the location of the OCSP Responder.- Parameters:
ocspResponderURL
- location of the OCSP Responder
-
setKeyStore
public void setKeyStore(KeyStore keyStore)
Set the key store.- Parameters:
keyStore
- the key store to set
-
getKeyStore
public KeyStore getKeyStore()
-
setTrustStore
public void setTrustStore(KeyStore trustStore)
Set the trust store.- Parameters:
trustStore
- the trust store to set
-
getTrustStore
public KeyStore getTrustStore()
-
setKeyStoreResource
public void setKeyStoreResource(Resource resource)
Set the key store resource.- Parameters:
resource
- the key store resource to set
-
getKeyStoreResource
public Resource getKeyStoreResource()
-
setTrustStoreResource
public void setTrustStoreResource(Resource resource)
Set the trust store resource.- Parameters:
resource
- the trust store resource to set
-
getTrustStoreResource
public Resource getTrustStoreResource()
-
isSessionCachingEnabled
public boolean isSessionCachingEnabled()
- Returns:
- true if SSL Session caching is enabled
-
setSessionCachingEnabled
public void setSessionCachingEnabled(boolean enableSessionCaching)
Set the flag to enable SSL Session caching. If set to true, then theSSLContext.createSSLEngine(String, int)
method is used to pass host and port information as a hint for session reuse. Note that this is only a hint and session may not be reused. Moreover, the hint is typically only used on client side implementations and setting this to false does not stop a server from accepting an offered session ID to reuse.- Parameters:
enableSessionCaching
- the value of the flag
-
getSslSessionCacheSize
public int getSslSessionCacheSize()
Get SSL session cache size. Passed directly toSSLSessionContext.setSessionCacheSize(int)
- Returns:
- SSL session cache size
-
setSslSessionCacheSize
public void setSslSessionCacheSize(int sslSessionCacheSize)
Set SSL session cache size.Set the max cache size to be set on
SSLSessionContext.setSessionCacheSize(int)
when this factory is started.- Parameters:
sslSessionCacheSize
- SSL session cache size to set. A value of -1 (default) uses the JVM default, 0 means unlimited and positive number is a max size.
-
getSslSessionTimeout
public int getSslSessionTimeout()
Get SSL session timeout.- Returns:
- SSL session timeout
-
setSslSessionTimeout
public void setSslSessionTimeout(int sslSessionTimeout)
Set SSL session timeout.Set the timeout in seconds to be set on
SSLSessionContext.setSessionTimeout(int)
when this factory is started.- Parameters:
sslSessionTimeout
- SSL session timeout to set in seconds. A value of -1 (default) uses the JVM default, 0 means unlimited and positive number is a timeout in seconds.
-
newSslServerSocket
public SSLServerSocket newSslServerSocket(String host, int port, int backlog) throws IOException
- Throws:
IOException
-
newSslSocket
public SSLSocket newSslSocket() throws IOException
- Throws:
IOException
-
newSSLEngine
public SSLEngine newSSLEngine()
Factory method for "scratch"SSLEngine
s, usually only used for retrieving configuration information such as the application buffer size or the list of protocols/ciphers.This method should not be used for creating
SSLEngine
s that are used in actual socket communication.- Returns:
- a new, "scratch"
SSLEngine
-
newSSLEngine
public SSLEngine newSSLEngine(String host, int port)
General purpose factory method for creatingSSLEngine
s, although creation ofSSLEngine
s on the server-side should prefernewSSLEngine(InetSocketAddress)
.- Parameters:
host
- the remote hostport
- the remote port- Returns:
- a new
SSLEngine
-
newSSLEngine
public SSLEngine newSSLEngine(InetSocketAddress address)
Server-side only factory method for creatingSSLEngine
s.If the given
address
is null, it is equivalent tonewSSLEngine()
, otherwisenewSSLEngine(String, int)
is called.If
getNeedClientAuth()
istrue
, then the host name is passed tonewSSLEngine(String, int)
, possibly incurring in a reverse DNS lookup, which takes time and may hang the selector (since this method is usually called by the selector thread).Otherwise, the host address is passed to
newSSLEngine(String, int)
without DNS lookup penalties.Clients that wish to create
SSLEngine
instances must usenewSSLEngine(String, int)
.- Parameters:
address
- the remote peer address- Returns:
- a new
SSLEngine
-
customize
public void customize(SSLEngine sslEngine)
Customize an SslEngine instance with the configuration of this factory, by callingcustomize(SSLParameters)
- Parameters:
sslEngine
- the SSLEngine to customize
-
customize
public SSLParameters customize(SSLParameters sslParams)
Customize an SslParameters instance with the configuration of this factory.- Parameters:
sslParams
- The parameters to customize- Returns:
- The passed instance of sslParams (returned as a convenience)
-
reload
public void reload(Consumer<SslContextFactory> consumer) throws Exception
- Throws:
Exception
-
getCertChain
public static X509Certificate[] getCertChain(SSLSession sslSession)
-
deduceKeyLength
public static int deduceKeyLength(String cipherSuite)
Given the name of a TLS/SSL cipher suite, return an int representing it effective stream cipher key strength. i.e. How much entropy material is in the key material being fed into the encryption routines.This is based on the information on effective key lengths in RFC 2246 - The TLS Protocol Version 1.0, Appendix C. CipherSuite definitions:
Effective Cipher Type Key Bits NULL * Stream 0 IDEA_CBC Block 128 RC2_CBC_40 * Block 40 RC4_40 * Stream 40 RC4_128 Stream 128 DES40_CBC * Block 40 DES_CBC Block 56 3DES_EDE_CBC Block 168
- Parameters:
cipherSuite
- String name of the TLS cipher suite.- Returns:
- int indicating the effective key entropy bit-length.
-
-