使用 https 时是否应该对 cookie 内容进行加密?
我试图在 https 下的 ASP.NET 中编写 cookie,但我在客户端计算机中看到纯文本 cookie。 在 https 连接下,cookie 不应该默认加密吗?
I'm trying to write a cookie in ASP.NET under https, but I see a plain text cookie in the client machine. Shouldn't the cookie be encrypted by default under an https connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
简短的回答是否定的,ASP.NET 中的 Cookie 不会在 SSL 下加密。 SSL 是一种传输级协议,仅加密客户端和服务器之间的通信。 Cookie 和查询字符串值未通过 SSL 加密。 一旦 cookie 位于客户端计算机上,它就会以其离开服务器时的格式保留。
Short answer is no, cookies are not encrypted in ASP.NET under SSL. SSL is a transport-level protocol, encrypting only the communications between the client and server. Cookies and query-string values are NOT encrypted by SSL. Once the cookie is on the client machine, it is left in whatever format it left the server in.
您的 cookie 仅在与您的浏览器之间传输 cookie 的过程中才会被加密。 如果您希望在浏览器的 cookie 存储中对 cookie 进行加密,则需要先在服务器上对其进行加密,然后在服务器端脚本中使用时在服务器上进行解密。
SSL/TLS 只是一种传输安全机制,用于加密线路上的请求/响应,由浏览器提供一种在客户端上安全存储 cookie 的机制(或者如上所述,您的应用程序可以执行此操作)。
Your cookie will only be encrypted during transmission of the cookie to/from your browser. If you want the cookie to be encrypted in the browser's cookie store, you'd need to encrypt it on the server first and then decrypt on the server upon use in server side scripts.
SSL/TLS is just a transport security mechanism to encrypt requests/responses on the wire, it is up to the browser to provide a mechanism to store cookies securely on the client (or as mentioned above, your application can do this).
不,据我所知,只有传输被加密,客户端的 cookie 没有加密。 为了更好的安全性,您应该自己加密它。
Nope, AFAIK only the transfer is encrypted, the cookie on the client side isn't. You should encrypt it yourself for better security.
它应该在线上加密,然后由浏览器解密。
It should be encrypted on the wire then decrypted by your browser.
如果您刚刚将 Django 从版本 2 更新到版本 3,并且您的 cookie 看起来有问题,请检查 django.contrib.messages.storage.cookie.CookieStorage._decode
Cookie 现在已“签名”。 如果你想直接访问它们,你需要
_decode()
它们。If you just updated Django from version 2 to 3 and something with your cookies looks wrong, check
django.contrib.messages.storage.cookie.CookieStorage._decode
Cookies are now "signed". If you want to directly access them, you need to
_decode()
them.