Skip to content

Shim to add cert-verified HTTPS connections to urllib2 communication options

License

Notifications You must be signed in to change notification settings

sjqzhang/urllib2.VerifiedHTTPS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TL;DR: The VerifiedHTTPSHandler class provides a way to do certificate-verified secure, HTTPS communication with urllib2.

Motivation

For Granola (http://grano.la), we needed a way to communicate with our REST server over a cert-verified HTTPS connection. urllib2 (http://docs.python.org/library/urllib2.html) provides a rich interface for opening URLs of various types, but it lacked certificate verification. This class provides an HTTPSHandler subclass (and associated connection class) for doing just that.

Example

See the file example.py for example usage. Note that the handler will do domain verification as well (assuming the flag is set), but I don't have a server with an installed signed cert with the wrong domain to test against.

Useful informations

This has been tested well on Python 2.6.2, but should work as far back as 2.4, assuming there is an ssl module (or an ssl_compat module.. we used to roll our own for older systems).

About

Shim to add cert-verified HTTPS connections to urllib2 communication options

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%