Class OpenSSLContext
java.lang.Object
org.apache.tomcat.util.net.openssl.OpenSSLContext
- All Implemented Interfaces:
SSLContext
OpenSSL implementation of the SSL context.
-
Constructor Summary
ConstructorsConstructorDescriptionOpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols) Constructs an OpenSSLContext for the given certificate and protocols.OpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols, boolean clientMode) Constructs an OpenSSLContext for the given certificate, protocols and client/server mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCertificate(SSLHostConfigCertificate certificate) Adds a certificate to this SSL context.protected static booleanapplyConf(OpenSSLConf conf, long cctx, long ctx) Applies the OpenSSL configuration commands to the given context.protected static booleancheckConf(OpenSSLConf conf, long cctx) Checks the OpenSSL configuration commands against the given context.Creates a new SSL engine.createSSLEngine(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.Returns the currently enabled SSL/TLS protocol.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) Setup the SSL_CTX.voidsetEnabledProtocol(String protocol) Sets the enabled SSL/TLS protocol.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SSLContext
getServedAlias
-
Constructor Details
-
OpenSSLContext
public OpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols) throws SSLException Constructs an OpenSSLContext for the given certificate and protocols.- Parameters:
certificate- The SSL host config certificatenegotiableProtocols- The list of negotiable protocols- Throws:
SSLException- if initialization fails
-
OpenSSLContext
public OpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols, boolean clientMode) throws SSLException Constructs an OpenSSLContext for the given certificate, protocols and client/server mode.- Parameters:
certificate- The SSL host config certificatenegotiableProtocols- The list of negotiable protocolsclientMode-truefor client mode, otherwise server mode- Throws:
SSLException- if initialization fails
-
-
Method Details
-
getEnabledProtocol
Returns the currently enabled SSL/TLS protocol.- Returns:
- The enabled protocol
-
setEnabledProtocol
Sets the enabled SSL/TLS protocol.- Parameters:
protocol- The protocol to enable, or null for the default
-
destroy
public void destroy()Description copied from interface:SSLContextDestroys this SSL context and releases any associated resources.- Specified by:
destroyin interfaceSSLContext
-
checkConf
Checks the OpenSSL configuration commands against the given context.- Parameters:
conf- The OpenSSL configurationcctx- The OpenSSL context- Returns:
- true if all commands are valid
- Throws:
Exception- if an error occurs
-
applyConf
Applies the OpenSSL configuration commands to the given context.- Parameters:
conf- The OpenSSL configurationcctx- The OpenSSL contextctx- The SSL context- Returns:
- true if all commands were applied successfully
- Throws:
Exception- if an error occurs
-
init
public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws KeyManagementException Setup the SSL_CTX.- Specified by:
initin interfaceSSLContext- Parameters:
kms- Must contain a KeyManager of the typeOpenSSLKeyManagertms- Must contain a TrustManager of the typeX509TrustManagersr- Is not used for this implementation.- Throws:
KeyManagementException- if an error occurs
-
addCertificate
Adds a certificate to this SSL context.- Parameters:
certificate- The certificate to add- Throws:
Exception- if an error occurs
-
getServerSessionContext
Description copied from interface:SSLContextReturns the server session context.- Specified by:
getServerSessionContextin interfaceSSLContext- Returns:
- The server session context
-
createSSLEngine
Description copied from interface:SSLContextCreates a new SSL engine.- Specified by:
createSSLEnginein interfaceSSLContext- Returns:
- The new SSL engine
-
createSSLEngine
Description copied from interface:SSLContextCreates a new SSL engine for the requested mode.- Specified by:
createSSLEnginein interfaceSSLContext- Parameters:
clientMode-truefor client mode, otherwise server mode- Returns:
- The new SSL engine
-
getServerSocketFactory
Description copied from interface:SSLContextReturns the server socket factory.- Specified by:
getServerSocketFactoryin interfaceSSLContext- Returns:
- The server socket factory
-
getSupportedSSLParameters
Description copied from interface:SSLContextReturns the supported SSL parameters.- Specified by:
getSupportedSSLParametersin interfaceSSLContext- Returns:
- The supported SSL parameters
-
getCertificateChain
Description copied from interface:SSLContextReturns the certificate chain for the given alias.- Specified by:
getCertificateChainin interfaceSSLContext- Parameters:
alias- The alias- Returns:
- The certificate chain
-
getServerKeyManagers
Description copied from interface:SSLContextReturns the key managers that may serve the given certificate configuration, in preference order. Used bySSLContext.getServedAlias(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.- Specified by:
getServerKeyManagersin interfaceSSLContext- Parameters:
certificate- The certificate configuration- Returns:
- The key managers that may serve the certificate, possibly empty, never
null
-
getAcceptedIssuers
Description copied from interface:SSLContextReturns the accepted issuers.- Specified by:
getAcceptedIssuersin interfaceSSLContext- Returns:
- The accepted issuers
-