Can';t发送代理凭据(407) 我尝试做一个代码连接C++程序,它需要一个需要密码和用户名认证的代理(IP:端口:用户名:PW),我得到HTTP工作,但是当我使用HTTPS时,我总是得到407的错误。p>

Can';t发送代理凭据(407) 我尝试做一个代码连接C++程序,它需要一个需要密码和用户名认证的代理(IP:端口:用户名:PW),我得到HTTP工作,但是当我使用HTTPS时,我总是得到407的错误。p>,c++,http,https,proxy,winhttp,C++,Http,Https,Proxy,Winhttp,如何以正确的方式在https上发送代理凭据?(C++)这很好,因为状态407意味着代理需要身份验证 所以你可以用这个: case 407: // The proxy requires authentication. printf( "The proxy requires authentication. Sending credentials...\n" ); // Obtain the supported and

如何以正确的方式在https上发送代理凭据?(C++)

这很好,因为状态407意味着代理需要身份验证

所以你可以用这个:

    case 407:
            // The proxy requires authentication.
            printf( "The proxy requires authentication.  Sending credentials...\n" );

            // Obtain the supported and preferred schemes.
            bResults = WinHttpQueryAuthSchemes( hRequest, 
                &dwSupportedSchemes, 
                &dwFirstScheme, 
                &dwTarget );

            // Set the credentials before resending the request.
            if( bResults )
                dwProxyAuthScheme = ChooseAuthScheme(dwSupportedSchemes);

            // If the same credentials are requested twice, abort the
            // request.  For simplicity, this sample does not check 
            // for a repeated sequence of status codes.
            if( dwLastStatus == 407 )
                bDone = TRUE;
            break;
功能

    DWORD ChooseAuthScheme( DWORD dwSupportedSchemes )
  {
//  It is the server's responsibility only to accept 
//  authentication schemes that provide a sufficient
//  level of security to protect the servers resources.
//
//  The client is also obligated only to use an authentication
//  scheme that adequately protects its username and password.
//
//  Thus, this sample code does not use Basic authentication  
//  becaus Basic authentication exposes the client's username
//  and password to anyone monitoring the connection.

if( dwSupportedSchemes & WINHTTP_AUTH_SCHEME_NEGOTIATE )
    return WINHTTP_AUTH_SCHEME_NEGOTIATE;
else if( dwSupportedSchemes & WINHTTP_AUTH_SCHEME_NTLM )
    return WINHTTP_AUTH_SCHEME_NTLM;
else if( dwSupportedSchemes & WINHTTP_AUTH_SCHEME_PASSPORT )
    return WINHTTP_AUTH_SCHEME_PASSPORT;
else if( dwSupportedSchemes & WINHTTP_AUTH_SCHEME_DIGEST )
    return WINHTTP_AUTH_SCHEME_DIGEST;
else
    return 0;
   } 
这将确定身份验证方案…然后使用

    bResults = WinHttpSetCredentials( hRequest, 
        WINHTTP_AUTH_TARGET_SERVER, 
        dwProxyAuthScheme,
        username,
        password,
        NULL );

我希望这能有所帮助……我也在和这些人一起工作,从azure marketplace连接到microsoft translator,因为它搬到了那里,从8月份开始,所有的老bing翻译人员都不会收到请求。对我来说,就是通过报头发送身份验证密钥。但我猜你有用户名和密码

非常感谢您的帮助!