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. -
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.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.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.
-
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
-
-
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
-
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
-
getAcceptedIssuers
Description copied from interface:SSLContextReturns the accepted issuers.- Specified by:
getAcceptedIssuersin interfaceSSLContext- Returns:
- The accepted issuers
-