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 Detail

      • init

        void init​(javax.net.ssl.KeyManager[] kms,
                  javax.net.ssl.TrustManager[] tms,
                  java.security.SecureRandom sr)
           throws java.security.KeyManagementException
        Initializes the SSL context with the given key managers, trust managers, and random number generator.
        Parameters:
        kms - The key managers
        tms - The trust managers
        sr - The secure random number generator
        Throws:
        java.security.KeyManagementException - if initialization fails
      • destroy

        void destroy()
        Destroys this SSL context and releases any associated resources.
      • getServerSessionContext

        javax.net.ssl.SSLSessionContext getServerSessionContext()
        Returns the server session context.
        Returns:
        The server session context
      • createSSLEngine

        javax.net.ssl.SSLEngine createSSLEngine()
        Creates a new SSL engine.
        Returns:
        The new SSL engine
      • createSSLEngine

        default javax.net.ssl.SSLEngine createSSLEngine​(boolean clientMode)
        Creates a new SSL engine for the requested mode.
        Parameters:
        clientMode - true for client mode, otherwise server mode
        Returns:
        The new SSL engine
      • getServerSocketFactory

        javax.net.ssl.SSLServerSocketFactory getServerSocketFactory()
        Returns the server socket factory.
        Returns:
        The server socket factory
      • getSupportedSSLParameters

        javax.net.ssl.SSLParameters getSupportedSSLParameters()
        Returns the supported SSL parameters.
        Returns:
        The supported SSL parameters
      • getCertificateChain

        java.security.cert.X509Certificate[] getCertificateChain​(java.lang.String alias)
        Returns the certificate chain for the given alias.
        Parameters:
        alias - The alias
        Returns:
        The certificate chain
      • getServerKeyManagers

        default javax.net.ssl.X509KeyManager[] getServerKeyManagers​(SSLHostConfigCertificate certificate)
        Returns the key managers that may serve the given certificate configuration, in preference order. Used by getServedAlias(org.apache.tomcat.util.net.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

        default java.lang.String getServedAlias​(SSLHostConfigCertificate certificate)
        Returns the alias of the certificate served for the given certificate configuration, for use with getCertificateChain(String). The key managers from getServerKeyManagers(org.apache.tomcat.util.net.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 from SSLHostConfigCertificate.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_ALIAS when 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 the NewSunX509 key manager.
        If no key manager names an alias, the configured (or default) alias is returned.

        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
      • getAcceptedIssuers

        java.security.cert.X509Certificate[] getAcceptedIssuers()
        Returns the accepted issuers.
        Returns:
        The accepted issuers