Using SSL proxies with WWW::Mechanize - why doesn't my HTTPS proxy setting work? · 16 January 2008, 11:34

WWW::Mechanize is a sub-class of the tried and true LWP package. The problem is that LWP does not properly support SSL proxying for any web server other than Apache; it issues an GET request to the proxy with the full URL to be requested as opposed to doing a CONNECT through the proxy in question. While most of us do work with Apache, there are certainly times when we will be using other types of proxies; in this case I was coding a test that goes through a Bluecoat hardware proxy.

To have SSL proxies work properly with WWW::Mechanize on non-Apache platforms , just install Crypt::SSLeay (which also installs Net::SSL) and then set the proxy URL into the environment in a variable named HTTPS_PROXY. Example:


If you forget the port part Crypt::SSLeay will not accept the proxy setting, error will look like this:

500 no port given for proxy server NN.NN.NN.NN

To enable debugging output at the Crypt::SSLeay level, just set the environment variable HTTPS_DEBUG to 1


Finally, to turn on debugging output for LWP in a script at run time (i.e. via command line option) just call LWP::Debug::level(’+’), this will turn on all debug levels for LWP, very useful for troubleshooting LWP scripts.


— Max Schubert



Textile Help