[英]Is CInternetSession secure? Is it being encrypted?
我向需要用戶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(){
}
}
GetHttpConnection
只是從WinInet庫調用WinAPI的InternetConnect
。 除非它通過帶有“ https://” URL的INTERNET_DEFAULT_HTTPS_PORT
選項的安全端口,否則它是不安全的。
可以說密碼是“藍芝士”。 如果我告訴您密碼,那么其他人都會看到它。 我可以用另一個密碼對密碼進行加密,然后我必須告訴您另一個密碼,其他人也會看到。 因此,除非使用Diffie-Hellman密鑰交換之類的方法,否則我無法通過開放渠道向您發送密碼。
如果該程序僅適合您自己,或者您可以保護其方法,則可以在軟件和網站之間建立一個挑戰系統。
如果您要編寫要公開發布的程序,那么基本上沒有SSL是不可能的,因為黑客可以監視您的代碼的工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.