gpt4 book ai didi

tomcat - 如何在 Tomcat 6 中从 SSL 恢复为非 SSL?

转载 作者:行者123 更新时间:2023-11-28 22:45:48 25 4
gpt4 key购买 nike

我正在使用 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"/>

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

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

我的配置有什么问题?

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

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

最佳答案

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

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

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

关于tomcat - 如何在 Tomcat 6 中从 SSL 恢复为非 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4537550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com