Java Servlet 过滤器和 SSL
Servlet 过滤器在检测 SSL 请求时是否有任何问题?
我有一个过滤器,可以正常处理正常的 http 请求,但它无法检测到 https 请求。
如有任何建议,我们将不胜感激。
Do Servlet filters have any issues with detecting SSL requests?
I have a filter that works okay with normal http request but it does not detect https request.
Any advice here would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知没有。
检查您的 Web 容器是否配置为侦听 HTTPS 请求。对于 Tomcat,请检查“server.xml”文件中的“connector”元素。
AFAIK no.
Check that your web container is configured to listen for HTTPS requests. For Tomcat, check the "connector" elements in your "server.xml" file.
我有一个适用于 SSL 和非 SSL 连接的 servlet 过滤器,并且我可以通过调用方法 HttpServletRequest.isSecure() 来确定连接是否是 SSL。因此,一旦在容器中正确配置了 SSL(这通常是棘手的部分),这应该可以工作。根据为容器设置 SSL 的文档检查配置,并在该文档中查找启用 SSL 调试的选项;这应该有助于确定出了什么问题。
I have a servlet filter that works with both SSL and non-SSL connections, and I can determine whether the connection is SSL or not by invoking the method HttpServletRequest.isSecure(). So this should work, once SSL is configured properly in the container (and that is usually the tricky part). Check the configuration against the documentation for setting up SSL for your container, and look in that documentation for an option to enable SSL debugging; that should help identify what is going wrong.