【发布时间】:2016-02-24 18:53:25
【问题描述】:
我向需要用户 credential 的 SharePoint 网站发出 HTTP POST 请求。
我想确保正在使用的username 和password 是安全的,不会被轻易嗅探。
我环顾四周,看看CInternetSession 是否对数据进行了加密,但我没有找到任何可靠的信息。
我使用此代码安全吗?
我正在通过这些证书如下:
void CUserPassDiag::Connect(){
CString username;
CString password;
m_UsernameCEditControl.GetWindowText(username); // get username
m_passwordCEditControl.GetWindowText(password); // get password
CInternetSession session(_T("session"));
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
const int szBuffSize = 20000;
char *szBuff = new char[szBuffSize]; // needed to store the html file
try
{
/*
* First Request - Retrieve the HTML page
*/
CString strServerName = _T("SPsite");
// Physyical Location Widget URL
CString strObject = _T("/somepage.aspx");
// Headers for the POST Request
CString headers = _T("Content-Type: application/x-www-form-urlencoded\r\n");
headers += _T("Host: SPsite\r\n");
headers += _T("Pragma: no-cache\r\n");
headers += _T("Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, *//*\r\n");
headers += _T("Accept-Language: en-CA\r\n");\
headers += _T("Referer: SPsite/somepage.aspx\r\n");
// Headers Ready
CString szHeaders = _T(headers);
// This will store the POST request return value
DWORD dwRet;
// Get connection with username and password
pServer = session.GetHttpConnection(strServerName, INTERNET_DEFAULT_HTTP_PORT, _T(username), _T(password));
// open request
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, strObject);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
}catch(){
}
}
【问题讨论】:
-
使用 SSL 让生活更轻松。您的网站是否支持
https://? -
不是
https,是http
标签: c++ http post encryption