0

我有一种情况,我需要将请求从非SSL端口重定向到SSL端口。我想出了以下代码,但它似乎没有重定向。

baseConnector = tomcat.getConnector();
    if (sslEnabled) {
        sslConnector = new Connector();
        sslConnector.setAttribute("keyAlias", "tomcat");
        sslConnector.setAttribute("keystorePass", "mypassword");
        sslConnector.setAttribute("keystoreFile", "pathtofile");
        sslConnector.setAttribute("clientAuth", "false");
        sslConnector.setAttribute("sslProtocol", "TLS");
        sslConnector.setAttribute("SSLEnabled", true);
        sslConnector.setProtocol("org.apache.coyote.http11.Http11NioProtocol");
        sslConnector.setSecure(true);
        sslConnector.setScheme("https");
        sslConnector.setPort(8443);
        tomcat.getService().addConnector(sslConnector);
        baseConnector.setRedirectPort(8443);
    }
4

1 回答 1

1

好像我必须在上下文中添加一个安全约束才能从非 SSL 端口重定向到 SSL 端口

于 2016-02-22T09:17:10.537 回答