campaignmonitor/createsend-python — pull request #17 by jdennes (2013-07-12 17:25:19+00:00)
Title: Better SSL Certificate Verification

This introduces the `VerifiedHTTPSConnection` class to enable better SSL certificate verification.

`VerifiedHTTPSConnection` extends `httplib.HTTPSConnection` but adds SSL certificate verification. The `CreateSendBase.make_request` method, which is used to make all API calls throughout the createsend library, uses an instance of `VerifiedHTTPSConnection` to make all API calls.

This method of certificate verification replaces the previous method, which was implemented in such a way that there were two separate networking calls made for every API call, one to verify the SSL certificate, and another to make the API call. That obviously wasn't that great.

More tests may eventually be added for the `match_hostname` method, although this code is take directly from [`backports.ssl_match_hostname`](https://pypi.python.org/pypi/backports.ssl_match_hostname). I didn't want to include a dependency on `backports.ssl_match_hostname` directly.

This library should eventually be refactored to use [requests](https://github.com/kennethreitz/requests) (which either didn't exist, or was in very early development when I started writing this library).