2

我想将 'secure' 标志设置为 JSESSIONID cookie 。tomcat 6中是否有此配置?

我尝试在 server.xml 的 'Connector' (8080) 元素中设置 'secure="true"' ,但它会产生问题 ....thats Connection is getting reset 。

请注意,在我的应用程序中,JSESSIONID 是以“http”模式(索引页面)创建的,当用户登录时,它将切换到“https”模式。

4

3 回答 3

3

如果您使用的是 tomcat 6,则可以执行以下解决方法

String sessionid = request.getSession().getId();
response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; secure ; HttpOnly");

有关更多信息,请参见https://www.owasp.org/index.php/HttpOnly

于 2012-08-13T11:41:19.790 回答
0

使用属性 useHttpOnly="true"。在 Tomcat9 中,默认值为 true。

于 2017-09-26T01:42:43.163 回答
0

对于 nginx 代理,可以在 nginx 配置中轻松解决:

if ($scheme = http) {
    return 301 https://$http_host$request_uri;
}

proxy_cookie_path / "/; secure";
于 2020-07-20T19:20:13.747 回答