python-3.x - 在 AWS SAML 联合登录中使用时 win32crypt.CryptUnprotectData 引发错误
问题描述
我正在尝试使用 AWS SAML 进行联邦登录,但下面有一个函数调用:
cookiesObj = getCookiesObj(
domain=args.domain,
username=args.username,
cookiefile=args.cookiefile,
useKeyring=args.keyring,
chromeprofile=args.chromeprofile
)
此调用转到以下代码:
c = sqlite3.connect(cookiefile)
sql = "SELECT name,encrypted_value FROM cookies " + \
"WHERE name IN ('" + ("','".join(requiredCookies)) + "')" + \
"AND host_key like '%{}%'".format(domain)
rows = c.cursor().execute(sql)
rowCount = 0
for k, ev in rows:
val = None
*val = win32crypt.CryptUnprotectData(ev, None, None, None, 0)[1]*
cookiesObj['cookies'][k] = val
rowCount += 1
尽管 sql 查询也返回带有 value(ev) 的 cookie MSISAuth,MSISAuth1,但 win32crypt 调用会引发错误:
Traceback (most recent call last):
File "aws_saml.py", line 435, in <module>
chromeprofile=args.chromeprofile
File "aws_saml.py", line 251, in getCookiesObj
val = win32crypt.CryptUnprotectData(ev, None, None, None, 0)[1]
pywintypes.error: (13, 'CryptProtectData', 'The data is invalid.')
使用的版本: pypiwin32==220 也尝试使用 223 pywin32==227
解决方案
推荐阅读
- unit-testing - 初始化循环 Golang
- qt - 操作的快捷方式不显示
- .htaccess - 我可以在共享托管 Apache 服务器上使用 RewriteMap 吗?
- c# - WebAPI 控制器看不到价值
- javascript - 项目映射时获取键和项目 onPress TouchableOpacity
- go - 在 Go 中使用 google oauth2
- c# - 导航按钮在 wpf 中无法正常工作
- typemock-isolator - 在 TypeMock 中模拟受保护的属性
- php - 使用 laravel artisan 迁移时出现 PHP 致命错误
- c# - 没有 App.config 的实体框架,数据库优先,存储库模式,N 层解决方案架构