问题描述
您好!我正在使用CFC的CInternetSession类来发送HTTP查询并获得结果。使用bith HTTP和HTTPS可以正常工作.CInternetSession cal的对象也会通过QueryOption返回会话的详细信息,这会带来选项。现在我尝试使用以下两个选项中的一个来提取证书:
Hello! I am using CInternetSession class of MFC to send HTTP queries and get results. Things work fine with bith HTTP and HTTPS.Objects of CInternetSession cal also return details of session by QueryOption which brings options. Now I am trying to extract certificate, using one of two options:
BYTE lpBuffer[2048];
DWORD lpdwBufferLength = sizeof(lpBuffer);
//CInternetSession session created before and valid and working
//attempt 1
BOOL resQueryOption = session.QueryOption((DWORD)INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, lpBuffer,&lpdwBufferLength);
DWORD erro1r = GetLastError(); //ERROR_INTERNET_INCORRECT_HANDLE_TYPE
//attempt 2
HINTERNET hInternet = (HINTERNET )session; //provides handle OK
BOOL resInternetQueryOption = InternetQueryOption( hInternet, INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, lpBuffer, &lpdwBufferLength);
DWORD error2 = GetLastError(); //ERROR_INTERNET_INCORRECT_HANDLE_TYPE
但是结果为FALSE,错误是ERROR_INTERNET_INCORRECT_HANDLE_TYPE(12018),即使我尝试做的样本也可以找到互联网。有什么不对的吗?
Levi
However the result is FALSE, and the error is ERROR_INTERNET_INCORRECT_HANDLE_TYPE (12018) even if I try to do like samples one can find in Internet. What can be wrong, please?
Levi
推荐答案
这篇关于以编程方式从CInternetSession中提取证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!