ServletRequest.issecure()== true但“ http” .equals(servletrequest.getscheme())

问题描述 投票:0回答:1

Context:我正在JDK11/TOMCAT9上托管的Spring应用程序5.3.x迁移到JDK21/TOMCAT11

举办的Spring 6.1.x 我的问题是,在迁移之后,当我在

Http

中请求过滤器时,返回true。
当然,在迁移之前,一切都按预期工作。
request.isSecure() 这会导致设置为jsessionId cookietosecure

防止浏览器以所有进一步的要求将其发送回去,因为我正在
http
.

中访问该应用程序。

任何想法都可能导致这个问题吗? 谢谢 enter image description here tomcat的配置(例如,对于tomcat9

)允许您配置任何连接器(Ctrl-f Secure)的属性

@WebFilter({"/xxx"}) public class MyFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { assert "http".equals(request.getScheme()); // it passes assert !request.isSecure(); // it fails // create the session here, it will set the JSESSIONID cookie request.getSession(true); chain.doFilter(request, response); } }

java spring session tomcat https
1个回答
0
投票
当然,当设置此设置时,Tomcat假设一切都很好 - 无论您是通过TLS-terminator/reverse-Proxy连接还是直接连接。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.