简体   繁体   English

什么是保护Cookie的最佳和最简便的方法

[英]What is the best and easiest way to secure cookies

I am searching for a way that help me to secure cookies by encrypting them for example. 我正在寻找一种方法,例如通过对cookie进行加密来帮助我保护cookie。 I searched a lot and I got confused. 我搜了很多东西,感到很困惑。 Thus, I am seeking your help to find an easy way to do that. 因此,我正在寻求您的帮助,以找到一种简便的方法。

Actually my aim is only to show that I can secure my cookies in Java for sensitive data such as password. 实际上,我的目的仅仅是表明我可以用Java保护cookie来保护敏感数据(例如密码)的安全。

In a protected connection (SSL), everything is encrypted, cookies too. 在受保护的连接(SSL)中,所有内容均已加密,Cookie也是如此。 Yes you can implement an algorithm to encrypt cookies value, why not... but you have to encrypt/decrypt handly with your own code. 是的,您可以实现一种算法来加密cookie值,为什么不这样做……但是您必须使用自己的代码手动进行加密/解密。

If you don't have a Java development tool, or the last paragraph scared you away from using one that you own, you can use the Java 2 Software Development Kit, which is available for free from Sun's Java Web site . 如果您没有Java开发工具,或者上一段吓到您不使用自己的Java开发工具,则可以使用Java 2软件开发工具包,该工具包可从Sun的Java网站免费获得。

In addition to delivering the cookies over HTTPS (SSL), and encrypting the contents such that they cannot be manipulated via Man in the Middle attacks, there is an additional requirement. 除了通过HTTPS(SSL)传递cookie并对内容进行加密以使它们无法通过“中间人攻击”来操纵外,还存在其他要求。 The cookie must also be marked as 'secure' per RFC2109 as in... 根据RFC2109,cookie还必须标记为“安全”,如...

//snip // SNIP

Set-Cookie:JSESSIONID:893ihewwydkq2764@&@09;Path=/;secure //snip Set-Cookie:JSESSIONID:893ihewwydkq2764 @&@ 09; Path = /; secure // snip

Marking the cookies this way ensures they cannot be delivered over an unencrypted session such as http. 以这种方式标记cookie可以确保它们无法通过未加密的会话(例如http)传递。

Using these three methods together makes a cookie reasonably 'SECURE' 结合使用这三种方法,可以使Cookie合理地“安全”

Happy coding :) 快乐的编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Java中操作ActiveX对象的最佳/最简单方法是什么? - What's the best/easiest way to manipulate ActiveX objects in Java? 将ContentValues转换为JSON字符串的最佳(最简单)方法是什么? - What's the best (easiest) way to convert ContentValues to a JSON string? 检测碰撞的最佳方法(或最简单)? - best way (or easiest) to detect collision? 在JAVA / Tomcat网站内保护购物车的最佳方法是什么? - What is the best way to secure a shopping cart within a JAVA/Tomcat website? 保护Flex-BlazeDS应用程序的最佳方法是什么? - What's the best way to secure a Flex-BlazeDS application? 在内部专用网络上保护SOAP Web服务的最佳方法是什么? - What is the best way to secure SOAP web service on an internal private network 使用 Java 保护查询字符串的最佳方法是什么? - What's the best way to secure a query string with Java? Play的内置缓存是否会过期? 如果没有,什么是最好的方法,或者也许是最简单的方法? - Does Play's built-in cache do sliding expiration? If not, what's the best way or perhaps the easiest way? 在Java中做“'是'最简单的方法是什么? - What is the easiest way to do 'is' in Java? 如果一段文字是垃圾邮件,那么检查Java的最佳,最简单,免费的方法是什么? - What's the best, easiest, free way to check in Java if a piece of text is spam?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM