【问题标题】:How to revert-back from SSL to non-SSL in Tomcat 6?如何在 Tomcat 6 中从 SSL 恢复到非 SSL?
【发布时间】:2011-05-31 01:38:33
【问题描述】:

我正在使用 jsf 2 + jaas + ssl + tomcat 6.0.26

我的网站中有 2 条路径:

/faces/protected/* 使用 SSL

/faces/unprotected/* 不使用 SSL。

我已经把它放在了我的 web.xml 中:

<login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/faces/login.jsp</form-login-page>
            <form-error-page>/faces/error.jsp</form-error-page>
        </form-login-config>
    </login-config>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Secure Resource</web-resource-name>
            <description/>
            <url-pattern>/faces/unprotected/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>           
        </web-resource-collection>
        <auth-constraint>
            <role-name>C</role-name>
        </auth-constraint>          
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Secure Resource</web-resource-name>
            <description />
            <url-pattern>/faces/protected/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>C</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>     
    </security-constraint>
    <security-role>
        <description> Role Client </description>
        <role-name>C</role-name>
    </security-role>

这是我的 server.xml:

 <Connector port="8080" protocol="HTTP/1.1" 
               maxThreads="400"
               maxKeepAliveRequests="1"
               acceptCount="100"
               connectionTimeout="3000"
               redirectPort="8443"
                compression="on"
                compressionMinSize="2048"
                noCompressionUserAgents="gozilla, traviata"
                compressableMimeType="text/javascript,text/css,text/html, text/xml,text/plain,application/x-javascript,application/javascript,application/xhtml+xml"  />


  <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" SSLEnabled="true"
               maxThreads="400" scheme="https" secure="true"
               clientAuth="optional" sslProtocol="TLS" 
               SSLCertificateFile="path/to/crt" 
               SSLCertificateKeyFile="path/to/pem"/>

当我进入受保护的路径时,它会切换到 HTTPS(端口 8443),但是当我进入路径 /faces/unprotected/somthing... 时,它仍然使用 HTTPS。

我想要的是当我进入未受保护的路径时,它会恢复为非 SSL 通信(否则,当我在浏览器中设置确切地址时,我必须再次重新登录)。

我的配置有什么问题?

有没有办法让我做这样的事情?

是否可以在不要求第二次认证的情况下调用页面?

【问题讨论】:

  • 只需重新安装它会是一个更简单的解决方案

标签: tomcat ssl tomcat6


【解决方案1】:

如果您在 HTTPS 下登录,然后返回到 HTTP,则您会将经过身份验证的 cookie 暴露给中间人攻击。这很糟糕。

您应该在会话通过身份验证的整个过程中保持 HTTPS。

与您的应用所做的工作相比,执行 SSL 所需的计算完全是微不足道的。坚持使用 SSL。

【讨论】:

    【解决方案2】:

    是的,这是 Tomcat 上的正常行为。

    一旦进入 https,它就不会将其他 URL 重定向回 http,除非该 URL 明确用于 http。

    如果你真的需要,你必须写一个Filter来检查URL是否不是安全模式的一部分,然后重定向回http。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-15
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    相关资源
    最近更新 更多