imperva / incapsula-logs-downloader

A Python script for downloading log files from Incapsula
MIT License
30 stars 35 forks source link

Migrate to urllib3 so it now also works via proxy #7

Closed dragazan closed 4 years ago

dragazan commented 4 years ago

I'm employed at an Imperva customer and was trying to implement this script on one of our Linux servers but needed to make it work via our corporate proxy.

There's already an open issue (https://github.com/imperva/incapsula-logs-downloader/issues/4) that's been raised for the original code not working via a proxy but this was wrongly blamed on the user's proxy.

After hopelessly trying to make the original code work, I've found out that there is indeed a bug (https://stackoverflow.com/a/41878564) in the original urllib2 SSLContext code which means the proxy won't ever be used; the proposed workaround given in the SO link didn't work.

I've had to spend a bit of time to migrate the code from urllib2 to urllib3 so that it now works via a proxy whenever there is one configured in the "Settings.Config" configuration file and I've successfully tested it for a few days now and it's working very well; just like the original, my code will also work when no proxy has been specified and also caters for when a user has/hasn't specified a custom CA file.

It would be great if you could please accept this and merge so other customers don't have to face this same issue in their environments.

Razvan Ragazan