【发布时间】:2015-09-24 00:12:46
【问题描述】:
我使用WinHttp 和WinHttpQueryOption API 特别是为了确保我的连接采用强https 加密。为此,我正在执行以下操作:
DWORD dwHttpSecurityFlags = 0;
DWORD dwcbSzSec = sizeof(dwHttpSecurityFlags);
if(WinHttpQueryOption(hRequest, WINHTTP_OPTION_SECURITY_FLAGS, &dwHttpSecurityFlags, &dwcbSzSec))
{
//Check security -- for connection to employ 128-bit encryption
if((dwHttpSecurityFlags & SECURITY_FLAG_SECURE) &&
(dwHttpSecurityFlags & (SECURITY_FLAG_STRENGTH_WEAK |
SECURITY_FLAG_STRENGTH_MEDIUM |
SECURITY_FLAG_STRENGTH_STRONG)) == SECURITY_FLAG_STRENGTH_STRONG)
{
//Passed security check
}
else
{
//Security check failed
}
}
else
{
//API Failed
}
但我不太清楚 SECURITY_FLAG_STRENGTH_* flags 是如何使用的——作为按位标志,还是作为唯一值?
如果我查看头文件,它们是这样定义的:
#define SECURITY_FLAG_SECURE 0x00000001 // can query only
#define SECURITY_FLAG_STRENGTH_WEAK 0x10000000
#define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000
#define SECURITY_FLAG_STRENGTH_STRONG 0x20000000
暗示按位使用,但连接同时使用 40 位和 128 位强加密没有意义。
有人可以澄清一下吗?我上面的代码正确吗?
【问题讨论】:
-
您到底想检查什么?我不明白你的条件代码。
-
@torvin:
Check security -- for connection to employ 128-bit encryption
标签: c++ c winapi https winhttp