Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util.ssl

public abstract Class SslContextFactory

extends ContainerLifeCycle
implements Dumpable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.component.Dumpable
Known Direct Subclasses
org.eclipse.jetty.util.ssl.SslContextFactory.Client, org.eclipse.jetty.util.ssl.SslContextFactory.Server
Annotations
@ManagedObject
Imports
java.io.ByteArrayInputStream, .IOException, java.net.InetAddress, .InetSocketAddress, .Socket, java.nio.charset.StandardCharsets, java.security.InvalidAlgorithmParameterException, .KeyStore, .NoSuchAlgorithmException, .Principal, .PrivateKey, .SecureRandom, .Security, java.security.cert.CRL, .CertStore, .CertStoreParameters, .Certificate, .CertificateException, .CertificateFactory, .CollectionCertStoreParameters, .PKIXBuilderParameters, .PKIXCertPathChecker, .X509CertSelector, .X509Certificate, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .HashMap, .LinkedHashSet, .List, .Map, .Objects, .Set, java.util.function.Consumer, java.util.regex.Matcher, .Pattern, java.util.stream.Collectors, javax.net.ssl.CertPathTrustManagerParameters, .HostnameVerifier, .KeyManager, .KeyManagerFactory, .SNIHostName, .SNIMatcher, .SNIServerName, .SSLContext, .SSLEngine, .SSLParameters, .SSLPeerUnverifiedException, .SSLServerSocket, .SSLServerSocketFactory, .SSLSession, .SSLSessionContext, .SSLSocket, .SSLSocketFactory, .StandardConstants, .TrustManager, .TrustManagerFactory, .X509ExtendedKeyManager, .X509ExtendedTrustManager, .X509TrustManager, org.eclipse.jetty.util.StringUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.ContainerLifeCycle, .Dumpable, org.eclipse.jetty.util.resource.Resource, .ResourceFactory, .Resources, org.eclipse.jetty.util.security.CertificateUtils, .CertificateValidator, .Password, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

SslContextFactory is used to configure SSL parameters to be used by server and client connectors.

Use Server to configure server-side connectors, and Client to configure HTTP or WebSocket clients.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static class
private static class
public static class
public static class
SslContextFactory.X509ExtendedKeyManagerWrapper

A wrapper that delegates to another (if not null) X509ExtendedKeyManager.

public static class
SslContextFactory.X509ExtendedTrustManagerWrapper

A wrapper that delegates to another (if not null) X509ExtendedTrustManager.

Field Summary

Modifier and TypeField and Description
private final Map<String, X509>
private String
private final Map<String, X509>
private final Map<String, X509>
private Comparator<String>
private String
private boolean
private boolean
private String
private final Set<String>
private final Set<String>
private SslContextFactory.Factory
private HostnameVerifier
private final Set<String>
private final Set<String>
private String
private Password
private Password
private String
private Resource
private String
private final AutoLock
private int
private String
private PKIXCertPathChecker
private boolean
private int
private String
private String[]
private String[]
private boolean
private SSLContext
private KeyStore
private KeyStore
private String
private String
private int
private int
private boolean
private String
private Password
private String
private Resource
private String
private boolean
private boolean
private boolean
private CertificateFactory
private static final String[]
DEFAULT_EXCLUDED_CIPHER_SUITES

Default Excluded Cipher Suite List

private static final String[]
DEFAULT_EXCLUDED_PROTOCOLS

Default Excluded Protocols List

public static final String
public static final String
private static final Pattern
public static final String
KEYPASSWORD_PROPERTY

String name of key password property.

private static final Logger
private static final Logger
public static final String
PASSWORD_PROPERTY

String name of keystore password property.

public static final TrustManager[]
private static final String

Constructor Summary

AccessConstructor and Description
protected
SslContextFactory()

Construct an instance of SslContextFactory with the default configuration.

public
SslContextFactory(boolean
whether to blindly trust all certificates
trustAll
)

Construct an instance of SslContextFactory that trusts all certificates

Method Summary

Modifier and TypeMethod and Description
public void
addExcludeCipherSuites(String... cipher)

You can either use the exact Cipher suite name or a a regular expression.

public void
addExcludeProtocols(String...
Protocol name patterns to add to SSLEngine#setEnabledProtocols(String[])
protocol
)

You can either use the exact Protocol name or a a regular expression.

pack-priv Map<String, X509>
protected void
protected void
protected void
private void
checkIsStarted()

Check if the lifecycle has been started and throw runtime exception

protected void
protected void
public void
customize(SSLEngine
the SSLEngine to customize
sslEngine
)

Customize an SslEngine instance with the configuration of this factory, by calling customize(SSLParameters)

public SSLParameters

Returns:

The passed instance of sslParams (returned as a convenience)
customize
(SSLParameters
The parameters to customize
sslParams
)

Customize an SslParameters instance with the configuration of this factory.

public static int

Returns:

int indicating the effective key entropy bit-length.
deduceKeyLength
(String
String name of the TLS cipher suite.
cipherSuite
)

Given the name of a TLS/SSL cipher suite, return an int representing it effective stream cipher key strength.

protected void
doStart()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Creates the SSLContext object and starts the lifecycle

protected void
doStop()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public String
public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

public Set<String>
public String
getCertAlias()

Returns: Alias of SSL certificate for the connector

public static X509Certificate[]

Returns:

the certificate chain
getCertChain
(SSLSession
the session to use for active peer certificates
sslSession
)

Obtain the X509 Certificate Chain from the provided SSLSession using this SslContextFactory's optional Provider specific CertificateFactory.

protected CertificateFactory
protected CertStore
public Comparator<String>
public String
getCrlPath()

Returns: Path to file that contains Certificate Revocation List

public String
getEndpointIdentificationAlgorithm()

Returns: the endpoint identification algorithm

public String[]
getExcludeCipherSuites()

Returns: The array of cipher suite name patterns to exclude from SSLEngine#setEnabledCipherSuites(String[])

public String[]
getExcludeProtocols()

Returns: The array of protocol names to exclude from SSLEngine#setEnabledProtocols(String[])

public HostnameVerifier

Returns:

the HostnameVerifier used by a client to verify host names in the server certificate
getHostnameVerifier
()

Get the HostnameVerifier used by a client to verify host names in the server certificate.

public String[]
getIncludeCipherSuites()

Returns: The array of Cipher suite names to include in SSLEngine#setEnabledCipherSuites(String[])

public String[]
getIncludeProtocols()

Returns: The array of protocol name patterns to include in SSLEngine#setEnabledProtocols(String[])

public String
getKeyManagerFactoryAlgorithm()

Returns: The algorithm name (default "SunX509") used by the KeyManagerFactory

protected KeyManagerFactory
public String
protected KeyManager[]
public KeyStore
public String
public String
getKeyStorePath()

Returns: The file or URL of the SSL Key store.

public String
getKeyStoreProvider()

Returns: The provider of the key store

public Resource
public String
getKeyStoreType()

Returns: The type of the key store (default "PKCS12")

public int
getMaxCertPathLength()

Returns: Maximum number of intermediate certificates in the certification path (-1 for unlimited)

public String
getOcspResponderURL()

Returns: Location of the OCSP Responder

protected Password

Returns:

the Password object
getPassword
(String
the realm
realm
)

Returns the password object for the given realm.

public PKIXCertPathChecker
public String
getProtocol()

Returns: The SSL protocol (default "TLS") passed to SSLContext#getInstance(String, String)

public String

Returns:

The optional Security Provider name.
getProvider
()

Get the optional Security Provider name.

public int
getRenegotiationLimit()

Returns: The number of renegotiations allowed for this connection.

public String
protected SecureRandom
public String[]
public String[]
public SSLContext
getSslContext()

Returns: The SSLContext

protected SSLContext
public int

Returns:

SSL session cache size
getSslSessionCacheSize
()

Get SSL session cache size.

public int

Returns:

SSL session timeout
getSslSessionTimeout
()

Get SSL session timeout.

public String
getTrustManagerFactoryAlgorithm()

Returns: The algorithm name (default "SunX509") used by the TrustManagerFactory

protected TrustManagerFactory
protected TrustManager[]
getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls)

public KeyStore
public String
public String
getTrustStoreProvider()

Returns: The provider of the trust store

public Resource
public String
getTrustStoreType()

Returns: The type of the trust store

public X509
getX509(String alias)

public X509Certificate[]

Returns:

the certificate chain
getX509CertChain
(SSLSession
the session to use for active peer certificates
sslSession
)

Obtain the X509 Certificate Chain from the provided SSLSession using this SslContextFactory's optional Provider specific CertificateFactory.

private static X509Certificate[]
getX509CertChain(CertificateFactory certificateFactory, SSLSession sslSession)

pack-priv Map<String, X509>
public boolean
isEnableCRLDP()

Returns: true if CRL Distribution Points support is enabled

public boolean
isEnableOCSP()

Returns: true if On-Line Certificate Status Protocol support is enabled

public boolean
isRenegotiationAllowed()

Returns: whether TLS renegotiation is allowed (true by default)

public boolean
isSessionCachingEnabled()

Returns: true if SSL Session caching is enabled

public boolean
isTrustAll()

Returns: True if all certificates should be trusted if there is no KeyStore or TrustStore

public boolean
public boolean
isValidateCerts()

Returns: true if SSL certificate has to be validated

public boolean
isValidatePeerCerts()

Returns: true if SSL certificates of the peer have to be validated

private void
load()

protected Collection<? extends CRL>

Returns:

Collection of CRL's
loadCRL
(String
path of certificate revocation list file
crlPath
)

Loads certificate revocation list (CRL) from a file.

protected KeyStore

Returns:

the key store instance
loadKeyStore
(Resource
the resource to load the keystore from
resource
)

Override this method to provide alternate way to load a keystore.

protected KeyStore

Returns:

the key store instance
loadTrustStore
(Resource
the resource to load the truststore from
resource
)

Override this method to provide alternate way to load a truststore.

public Password

Returns:

the new Password object
newPassword
(String
the password string
password
)

Creates a new Password object.

protected PKIXBuilderParameters
newPKIXBuilderParameters(KeyStore trustStore, Collection<? extends CRL> crls)

public SSLEngine

Returns:

a new, "scratch" SSLEngine
newSSLEngine
()

Factory method for "scratch" SSLEngines, usually only used for retrieving configuration information such as the application buffer size or the list of protocols/ciphers.

public SSLEngine

Returns:

a new SSLEngine
newSSLEngine
(String
the remote host
host
,
int
the remote port
port
)

General purpose factory method for creating SSLEngines, although creation of SSLEngines on the server-side should prefer newSSLEngine(InetSocketAddress).

public SSLEngine

Returns:

a new SSLEngine
newSSLEngine
(InetSocketAddress
the remote peer address
address
)

Server-side only factory method for creating SSLEngines.

public SSLServerSocket
newSslServerSocket(String host, int port, int backlog)

public SSLSocket
protected void
processIncludeCipherSuites(String[] supportedCipherSuites, List<String> selectedCiphers)
Deprecated no replacement

private List<String>
processIncludeExcludePatterns(String type, String[] enabled, String[] supported, Set<String> included, Set<String> excluded)

public void
protected void
removeExcludedCipherSuites(List<String> selectedCiphers)
Deprecated no replacement

protected void
selectCipherSuites(String[]
Array of enabled cipher suites
enabledCipherSuites
,
String[]
Array of supported cipher suites
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.

pack-priv List<SslSelectionDump>
public void
selectProtocols(String[]
Array of enabled protocols
enabledProtocols
,
String[]
Array of supported protocols
supportedProtocols
)

Select protocols to be used by the connector based on configured inclusion and exclusion lists as well as enabled and supported protocols.

public void
setCertAlias(String
Alias of SSL certificate for the connector
certAlias
)

Set the default certificate Alias.

public void
public void
setCrlPath(String
Path to file that contains Certificate Revocation List
crlPath
)

public void
setEnableCRLDP(boolean
true - turn on, false - turns off
enableCRLDP
)

Enables CRL Distribution Points Support

public void
setEnableOCSP(boolean
true - turn on, false - turn off
enableOCSP
)

Enables On-Line Certificate Status Protocol support

public void
setEndpointIdentificationAlgorithm(String
Set the endpointIdentificationAlgorithm
endpointIdentificationAlgorithm
)

When set to "HTTPS" hostname verification will be enabled.

public void
setExcludeCipherSuites(String...
The array of cipher suite names to exclude from SSLEngine#setEnabledCipherSuites(String[])
cipherSuites
)

You can either use the exact Cipher suite name or a a regular expression.

public void
setExcludeProtocols(String...
The array of protocol names to exclude from SSLEngine#setEnabledProtocols(String[])
protocols
)

You can either use the exact Protocol name or a a regular expression.

public void
setHostnameVerifier(HostnameVerifier
the HostnameVerifier used by a client to verify host names in the server certificate
hostnameVerifier
)

Sets a HostnameVerifier used by a client to verify host names in the server certificate.

public void
setIncludeCipherSuites(String...
The array of cipher suite names to include in SSLEngine#setEnabledCipherSuites(String[])
cipherSuites
)

You can either use the exact Cipher suite name or a a regular expression.

public void
setIncludeProtocols(String...
The array of protocol name patterns to include in SSLEngine#setEnabledProtocols(String[])
protocols
)

You can either use the exact Protocol name or a a regular expression.

public void
setKeyManagerFactoryAlgorithm(String
The algorithm name (default "SunX509") used by the KeyManagerFactory
algorithm
)

public void
setKeyManagerPassword(String
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 the getPassword(String) is used to obtain a password from the org.eclipse.jetty.ssl.keypassword system property.
password
)

public void
setKeyStore(KeyStore
the key store to set
keyStore
)

Set the key store.

public void
setKeyStorePassword(String
The password for the key store. If null is passed and a keystore is set, then the getPassword(String) is used to obtain a password either from the org.eclipse.jetty.ssl.password system property.
password
)

public void
setKeyStorePath(String
The file or URL of the SSL Key store.
keyStorePath
)

public void
setKeyStoreProvider(String
The provider of the key store
keyStoreProvider
)

public void
setKeyStoreResource(Resource
the key store resource to set
resource
)

Set the key store resource.

public void
setKeyStoreType(String
The type of the key store
keyStoreType
)

public void
setMaxCertPathLength(int
maximum number of intermediate certificates in the certification path (-1 for unlimited)
maxCertPathLength
)

public void
setOcspResponderURL(String
location of the OCSP Responder
ocspResponderURL
)

Set the location of the OCSP Responder.

public void
public void
setProtocol(String
The SSL protocol (default "TLS") passed to SSLContext#getInstance(String, String)
protocol
)

public void
setProvider(String
The optional Security Provider name.
provider
)

Set the optional Security Provider name.

public void
setRenegotiationAllowed(boolean
whether TLS renegotiation is allowed
renegotiationAllowed
)

Set whether TLS renegotiation is allowed.

public void
setRenegotiationLimit(int
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.
renegotiationLimit
)

public void
public void
setSessionCachingEnabled(boolean
the value of the flag
enableSessionCaching
)

Set the flag to enable SSL Session caching.

public void
setSslContext(SSLContext
Set a preconfigured SSLContext
sslContext
)

public void
setSslSessionCacheSize(int
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.
sslSessionCacheSize
)

Set SSL session cache size.

public void
setSslSessionTimeout(int
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.
sslSessionTimeout
)

Set SSL session timeout.

public void
setTrustAll(boolean
True if all certificates should be trusted if there is no KeyStore or TrustStore
trustAll
)

public void
setTrustManagerFactoryAlgorithm(String
The algorithm name (default "SunX509") used by the TrustManagerFactory Use the string "TrustAll" to install a trust manager that trusts all.
algorithm
)

public void
setTrustStore(KeyStore
the trust store to set
trustStore
)

Set the trust store.

public void
setTrustStorePassword(String
The password for the truststore. If null is passed then the getPassword(String) is used to obtain a password from the org.eclipse.jetty.ssl.password system property.
password
)

public void
setTrustStorePath(String
The file name or URL of the trust store location
trustStorePath
)

public void
setTrustStoreProvider(String
The provider of the trust store
trustStoreProvider
)

public void
setTrustStoreResource(Resource
the trust store resource to set
resource
)

Set the trust store resource.

public void
setTrustStoreType(String
The type of the trust store
trustStoreType
)

public void
setUseCipherSuitesOrder(boolean useCipherSuitesOrder)

public void
setValidateCerts(boolean
true if SSL certificates have to be validated
validateCerts
)

Set true if SSL certificates have to be validated.

public void
setValidatePeerCerts(boolean
true if SSL certificates of the peer have to be validated
validatePeerCerts
)

Set true if SSL certificates of the peer have to be validated.

public String
toString()

Overrides org.eclipse.jetty.util.component.AbstractLifeCycle.toString.

Returns a string representation of the object.

private void
public void
pack-priv Map<String, X509>
Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans