amrapali builders@@@hacking d link routers with hnap.pdf
Curl error 407 proxy authentication required
1. CURL Error : 407 Proxy Authentication Required
Curl is a module used in Php and several applications require it to meet the development needs.
This happened one day when one of developers came up and said, hey Curl is giving the
following error below
Technical Information (for support personnel)
* Error Code: 407 Proxy Authentication Required. Forefront TMG requires authorization to
fulfill the request. Access to the Web Proxy filter is denied. (12209)
* IP Address: 10.10.1.20
* Date: 8/10/2010 9:28:56 AM [GMT]
* Server: proxyserver.yourdomain.com
* Source: proxy
going through several options and forums i was quite exhaused as forums were reporting this
issue that when Threat Management Gateway (TMG) or ISA server is running in the network,
the applications running curl behind the firewall cannot pass through but didnt provided how to
fix it. I did every other settings possible in my firewall to allow it but no luck. The following was
the solution that worked
$f=fopen("error.txt","w");
$ch = curl_init("http://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); // follow redirects recursively
curl_setopt($ch, CURLOPT_STDERR, $f);
curl_setopt($ch, CURLOPT_PROXY, “http://proxyserver:8080″);
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, “yourdomain.comusername:password”);
$x = curl_exec($ch);
//print “page:” .$x . curl_error($ch) ;
$info = curl_getinfo($ch);
print “
";print_r($info);
curl_close($ch);
?>
2. The only line i missed was to set authentication as NTLM
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
Hope this helps someone facing this issue!