【问题标题】:Is CInternetSession secure? Is it being encrypted?CInternetSession 安全吗?是不是被加密了?
【发布时间】:2016-02-24 18:53:25
【问题描述】:

我向需要用户 credential 的 SharePoint 网站发出 HTTP POST 请求。

我想确保正在使用的usernamepassword 是安全的,不会被轻易嗅探。

我环顾四周,看看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


【解决方案1】:

GetHttpConnection 只是从 WinInet 库中调用 WinAPI 的 InternetConnect。除非它通过带有“https://”URL 的 INTERNET_DEFAULT_HTTPS_PORT 选项的安全端口,否则它是不安全的。

假设密码是“blue-cheese”。如果我告诉你密码,那么其他人都会看到它。我可以用另一个密码加密密码,然后我必须告诉你另一个密码,其他人也会看到。因此,除非使用 Diffie-Hellman 密钥交换等方法,否则我无法通过公开渠道向您发送密码。

如果该程序仅供您自己使用,或者您可以保护其方法,那么您可以在您的软件和您的网站之间建立一个响应挑战系统。

如果您正在制作一个公开发布的程序,那么如果没有 SSL,这基本上是不可能的,因为黑客可以监控您的代码的作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    • 2011-08-04
    相关资源
    最近更新 更多