Search in sources :

Example 16 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project tomcat by apache.

the class ManagerServlet method sslReload.

protected void sslReload(PrintWriter writer, String tlsHostName, StringManager smClient) {
    Connector[] connectors = getConnectors();
    boolean found = false;
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
            ProtocolHandler protocol = connector.getProtocolHandler();
            if (protocol instanceof AbstractHttp11Protocol<?>) {
                AbstractHttp11Protocol<?> http11Protoocol = (AbstractHttp11Protocol<?>) protocol;
                if (tlsHostName == null || tlsHostName.length() == 0) {
                    found = true;
                    http11Protoocol.reloadSslHostConfigs();
                } else {
                    SSLHostConfig[] sslHostConfigs = http11Protoocol.findSslHostConfigs();
                    for (SSLHostConfig sslHostConfig : sslHostConfigs) {
                        // comparison as host names are case insensitive.
                        if (sslHostConfig.getHostName().equalsIgnoreCase(tlsHostName)) {
                            found = true;
                            http11Protoocol.reloadSslHostConfig(tlsHostName);
                        }
                    }
                }
            }
        }
    }
    if (found) {
        if (tlsHostName == null || tlsHostName.length() == 0) {
            writer.println(smClient.getString("managerServlet.sslReloadAll"));
        } else {
            writer.println(smClient.getString("managerServlet.sslReload", tlsHostName));
        }
    } else {
        writer.println(smClient.getString("managerServlet.sslReloadFail"));
    }
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) Connector(org.apache.catalina.connector.Connector) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol)

Aggregations

AbstractHttp11Protocol (org.apache.coyote.http11.AbstractHttp11Protocol)16 ProtocolHandler (org.apache.coyote.ProtocolHandler)7 ByteBuffer (java.nio.ByteBuffer)5 Connector (org.apache.catalina.connector.Connector)4 TomcatConnectorCustomizer (org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer)3 TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)3 Bean (org.springframework.context.annotation.Bean)3 IOException (java.io.IOException)2 SpringApplication (org.springframework.boot.SpringApplication)2 SpringBootApplication (org.springframework.boot.autoconfigure.SpringBootApplication)2 MultipartConfigElement (jakarta.servlet.MultipartConfigElement)1 ServletContext (jakarta.servlet.ServletContext)1 ServletException (jakarta.servlet.ServletException)1 Dynamic (jakarta.servlet.ServletRegistration.Dynamic)1 HttpServlet (jakarta.servlet.http.HttpServlet)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 SocketException (java.net.SocketException)1