惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Secure Thoughts
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Blog of Author Tim Ferriss
B
Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
T
The Exploit Database - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
Google Online Security Blog
Google Online Security Blog
T
Troy Hunt's Blog
I
InfoQ
L
LINUX DO - 热门话题
WordPress大学
WordPress大学
C
Cisco Blogs
G
GRAHAM CLULEY
The Register - Security
The Register - Security
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Schneier on Security
Schneier on Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
H
Hacker News: Front Page
小众软件
小众软件
雷峰网
雷峰网
The Hacker News
The Hacker News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Tor Project blog
博客园 - 聂微东
N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
The GitHub Blog
The GitHub Blog
腾讯CDC
P
Palo Alto Networks Blog
Scott Helme
Scott Helme

博客园 - 心愿

IIS上启用Gzip对网页进行压缩(图文) 健康养生:掌握规律,合理睡眠 SQL Server 数据库出现 置疑的处理方法 . Windows补丁:安装程序不能验证Update.inf文件的完整性,请确定加密服务正在此计算机上运行 使用URLRewriter重写后,相同后缀后的真实静态文件无法访问的解决办法 Sql server WaitType 日志 【转载】办公室禁止QQ登录的用法 [转]SQL Server 2005新特性 [转]艾瑞咨询:网络招聘的顺势突围之道 [收藏]sql查询性能调试,用SET STATISTICS IO和SET STATISTICS TIME 关于未能创建 Mutex 问题的解决 [摘录]Windows Server十大隐患服务 [收集]自己编写一个SQL Server中用的lastindexof函数 [收集|整理]优化SQL Server数据库相关注意事项 [收集]精典诗词改篇:沁园春 车票 [转]NUnit2.0详细使用方法 [转]利用UrlRewriter 实现二级域名 熬夜——健康的天敌 Asp.net中基于Forms验证的角色验证授权
二级域名共享Cookie时碰到的问题:Padding is invalid and cannot be removed
心愿 · 2008-10-23 · via 博客园 - 心愿

2008-10-23 16:42  心愿  阅读(408)  评论()    收藏  举报

最近因为工作的原因,要实现 二级域名的站点跟主站点共享用户登陆身份的功能。

想了想,最简单,各站点改动最少,最省事的莫过于通过设置 Cookie 的 Domain 属性值来实现了。

于是参考了下 Zendy 的相关文章 http://www.cnblogs.com/caomao/archive/2005/07/05/186606.html 后,便开始了。

一切顺利,^_^,汗,因本来就不难,要本地调试通过。于是放到服务器去,天哪,出错:

Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed

仔细检查,没少传什么东西呀,本地跟服务器上程序是一致的,怎么本地行,服务器上就不行了呢!奇怪了。

于是 google,baidu 了一番,结果是众说纷云,杂七杂八,有说是权限问题的,有说是设置问题,还有很多是提出问题后,根本没人回答的。

搞了好久,没搞定,后来静下心来一想,这应该是很简单的问题,其它人应该都很顺利搞定的,应该都没出过这个错误。

想呀想,想呀想,终于找出了本地跟服务器上的区别。

    真是笨,笨死啦。本地测的程序全是用VS2003写的,而服务器上,因主站是比较早做的,是VS2003写的,而现在要调用的子站是用VS2005写的,

一想到这,就觉得应该是两个版本间 产生的 验证票据的加解密方法所采用的机制不一样。于是进行修改:

string HashTicket = FormsAuthentication.Encrypt(ticket)

把上面这句去掉,同时把读取 Cookie 时的解密的那句也去掉。搞定。

不过去掉后,Cookie 就是明码了,安全方面需考虑下。至于有没有其它解决方法,正在找。。。

^_^,才孰学浅,写的不对之处,还希望有高人能批评指正!谢谢!