campaignmonitor / createsend-python

A Python library for the Campaign Monitor API
http://campaignmonitor.github.io/createsend-python
MIT License
57 stars 63 forks source link

Better SSL Certificate Verification #17

Closed jdennes closed 11 years ago

jdennes commented 11 years ago

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. I didn't want to include a dependency on backports.ssl_match_hostname directly.

This library should eventually be refactored to use requests (which either didn't exist, or was in very early development when I started writing this library).

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling df7a77164b62d765110e9e00dec125f52b39b5cc on better-ssl-cert-verification into da6e1c1e988ecb59aa0012cafb700a8bb36d383e on master.