Peter Meier
2005-09-07 13:02:21 UTC
Hi,
When I am trying to use wininet to authenticate through a proxy on a
server which also requires authentication, it works fine, if the server
is running on HTTP. If the server requires HTTPS the authorization
fails. Here's a code snippet:
...
BOOL bSendHttpRequest = HttpSendRequest(m_hHttpOpenRequest, NULL, 0,
NULL, 0);
DWORD dwStatus;
DWORD dwBufSize = sizeof(dwStatus);
HttpQueryInfo(m_hHttpOpenRequest, HTTP_QUERY_STATUS_CODE, &dwStatus,
&dwBufSize, 0);
BYTE strBuffer[2048];
DWORD dwBufSize = sizeof(strBuffer);
memset(strBuffer, 0, dwBufSize);
if (dwBufSize == HTTP_STATUS_PROXY_AUTH_REQ) // 407: Proxy
authentication required
{
strHeader = "Authorization: Basic aW5zdXJlcjpkZW1v" + "\r\n" +
"Proxy-Authorization: Basic YXVkYXRleDphdWRhdGV4" +
"\r\n" ;
bSendHttpRequest = HttpSendRequest(m_hHttpOpenRequest, strHeader,
strHeader.GetLength(), NULL, 0);
}
...
I have also tried to use
InternetSetOption(m_hHttpOpenRequest, INTERNET_OPTION_PROXY_USERNAME,
&strProxyUsername, strProxyUsername.GetLength());
InternetSetOption(m_hHttpOpenRequest, INTERNET_OPTION_PROXY_PASSWORD,
&strProxyPassword, strProxyPassword.GetLength());
instead of sending the header manually, but still it doesn't work.
When I do a network trace I can see that in the HTTP case, a 'GET'
request is send to the server together with the 'Proxy-Authorization'
header. Whereas in the HTTPS case my 'GET' request automatically
becomes a 'CONNECT' request and although I set the 'Proxy
Authorization' header I can see that it is not send (it does not appear
in the network trace)? Does anybody have an idea why the header is not
send in the 'CONNECT' case? Thanks a lot for any suggestions!
Peter
When I am trying to use wininet to authenticate through a proxy on a
server which also requires authentication, it works fine, if the server
is running on HTTP. If the server requires HTTPS the authorization
fails. Here's a code snippet:
...
BOOL bSendHttpRequest = HttpSendRequest(m_hHttpOpenRequest, NULL, 0,
NULL, 0);
DWORD dwStatus;
DWORD dwBufSize = sizeof(dwStatus);
HttpQueryInfo(m_hHttpOpenRequest, HTTP_QUERY_STATUS_CODE, &dwStatus,
&dwBufSize, 0);
BYTE strBuffer[2048];
DWORD dwBufSize = sizeof(strBuffer);
memset(strBuffer, 0, dwBufSize);
if (dwBufSize == HTTP_STATUS_PROXY_AUTH_REQ) // 407: Proxy
authentication required
{
strHeader = "Authorization: Basic aW5zdXJlcjpkZW1v" + "\r\n" +
"Proxy-Authorization: Basic YXVkYXRleDphdWRhdGV4" +
"\r\n" ;
bSendHttpRequest = HttpSendRequest(m_hHttpOpenRequest, strHeader,
strHeader.GetLength(), NULL, 0);
}
...
I have also tried to use
InternetSetOption(m_hHttpOpenRequest, INTERNET_OPTION_PROXY_USERNAME,
&strProxyUsername, strProxyUsername.GetLength());
InternetSetOption(m_hHttpOpenRequest, INTERNET_OPTION_PROXY_PASSWORD,
&strProxyPassword, strProxyPassword.GetLength());
instead of sending the header manually, but still it doesn't work.
When I do a network trace I can see that in the HTTP case, a 'GET'
request is send to the server together with the 'Proxy-Authorization'
header. Whereas in the HTTPS case my 'GET' request automatically
becomes a 'CONNECT' request and although I set the 'Proxy
Authorization' header I can see that it is not send (it does not appear
in the network trace)? Does anybody have an idea why the header is not
send in the 'CONNECT' case? Thanks a lot for any suggestions!
Peter