tomcat cookie域验证

tomcat cookie域验证,tomcat,cookies,Tomcat,Cookies,我正在使用tomcat 8.0.21和新的Rfc6265 cookie处理器。如果有以点开头的cookie,我会得到以下错误: java.lang.IllegalArgumentException: An invalid domain [.db-app.de] was specified for this cookie org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.

我正在使用tomcat 8.0.21和新的Rfc6265 cookie处理器。如果有以点开头的cookie,我会得到以下错误:

java.lang.IllegalArgumentException: An invalid domain [.db-app.de] was specified for this cookie
org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:180)
org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:122)
org.apache.catalina.connector.Response.generateCookieString(Response.java:959)
org.apache.catalina.connector.Response.addCookie(Response.java:907)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:392)
org.esigate.servlet.impl.ResponseSender.sendResponse(ResponseSender.java:70)
com.bahn.esiExtensions.ExtendedProxyServlet.doFilter(ExtendedProxyServlet.java:104)

有没有办法防止tomcat抛出这个错误

使用Tomcat 8上的新cookie处理器,cookie域必须以数字或字母开头。删除前导点应该可以消除此错误


尝试将其改为
dot.db app.de
,或者给它一个全新的名称。

您可以通过在context.xml文件中定义旧cookie处理器来恢复Tomcat的行为


请参见

我正在使用Tomcat 8的新版本(从去年10月开始),在添加强制使用传统cookie处理器的行之后,它工作正常。 在您的
${catalina.base}conf/context.xml
上:

<Context>

<!-- Default set of monitored resources. If one of these changes, the    -->
<!-- web application will be reloaded.                                   -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

<!-- Force use the old Cookie processor (because this new tomcat version uses RFC6265 Cookie Specification) -->
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />

WEB-INF/WEB.xml
${catalina.base}/conf/web.xml

我希望这可能是你的情况。只需设置这个CookieProcessor,您的实现就会像以前版本的Tomcat8一样工作