Interface SSLContext
- All Known Implementing Classes:
OpenSSLContext
public interface SSLContext
This interface is needed to override the default SSLContext class to allow SSL implementation pluggability without
having to use JCE. With regular JSSE it will do nothing but delegate to the SSLContext.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new SSL engine.default SSLEnginecreateSSLEngine(boolean clientMode) Creates a new SSL engine for the requested mode.voiddestroy()Destroys this SSL context and releases any associated resources.Returns the accepted issuers.getCertificateChain(String alias) Returns the certificate chain for the given alias.default StringgetServedAlias(SSLHostConfigCertificate certificate) Returns the alias of the certificate served for the given certificate configuration, for use withgetCertificateChain(String).default X509KeyManager[]getServerKeyManagers(SSLHostConfigCertificate certificate) Returns the key managers that may serve the given certificate configuration, in preference order.Returns the server session context.Returns the server socket factory.Returns the supported SSL parameters.voidinit(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) Initializes the SSL context with the given key managers, trust managers, and random number generator.
-
Method Details
-
init
Initializes the SSL context with the given key managers, trust managers, and random number generator.- Parameters:
kms- The key managerstms- The trust managerssr- The secure random number generator- Throws:
KeyManagementException- if initialization fails
-
destroy
void destroy()Destroys this SSL context and releases any associated resources. -
getServerSessionContext
SSLSessionContext getServerSessionContext()Returns the server session context.- Returns:
- The server session context
-
createSSLEngine
-
createSSLEngine
Creates a new SSL engine for the requested mode.- Parameters:
clientMode-truefor client mode, otherwise server mode- Returns:
- The new SSL engine
-
getServerSocketFactory
SSLServerSocketFactory getServerSocketFactory()Returns the server socket factory.- Returns:
- The server socket factory
-
getSupportedSSLParameters
SSLParameters getSupportedSSLParameters()Returns the supported SSL parameters.- Returns:
- The supported SSL parameters
-
getCertificateChain
Returns the certificate chain for the given alias.- Parameters:
alias- The alias- Returns:
- The certificate chain
-
getServerKeyManagers
Returns the key managers that may serve the given certificate configuration, in preference order. Used bygetServedAlias(SSLHostConfigCertificate)to resolve the alias actually served. The default returns an empty array (no key manager known); implementations backed by one or more key managers override it to expose them.- Parameters:
certificate- The certificate configuration- Returns:
- The key managers that may serve the certificate, possibly empty, never
null
-
getServedAlias
Returns the alias of the certificate served for the given certificate configuration, for use withgetCertificateChain(String). The key managers fromgetServerKeyManagers(SSLHostConfigCertificate)are consulted in preference order and the first one that names an alias decides, just as JSSE only uses the first key manager:- A
JSSEKeyManager, which Tomcat pins to an alias, serves that alias in every handshake. This can differ fromSSLHostConfigCertificate.getCertificateKeyAlias(), for example after SunMSCAPI Windows-MY numbered-duplicate resolution. - Any other key manager chooses an alias itself, for example one from a FIPS key manager factory, which Tomcat
does not wrap, or one over an in-memory key store that holds only the selected key. The configured alias
(or
SSLUtilBase.DEFAULT_KEY_ALIASwhen none is configured) is used if that key manager holds it, otherwise the alias it would choose - for example for a key that an in-memory key store holds under another alias, or the synthetic alias generated by theNewSunX509key manager.
For a key manager that Tomcat does not wrap, such as one from a FIPS key manager factory, the result is the configured alias when that key manager holds it. A JSSE handshake may nevertheless be served a different entry, as the key manager chooses per handshake, for example by key type or server name, and this cannot be predicted. Certificate monitoring based on the result is therefore only reliable if the configured alias identifies the certificate that is served.
- Parameters:
certificate- The certificate configuration- Returns:
- The served alias, never
null
- A
-
getAcceptedIssuers
-