README.txt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. The ssl.match_hostname() function from Python 3.4
  2. =================================================
  3. The Secure Sockets layer is only actually *secure*
  4. if you check the hostname in the certificate returned
  5. by the server to which you are connecting,
  6. and verify that it matches to hostname
  7. that you are trying to reach.
  8. But the matching logic, defined in `RFC2818`_,
  9. can be a bit tricky to implement on your own.
  10. So the ``ssl`` package in the Standard Library of Python 3.2
  11. and greater now includes a ``match_hostname()`` function
  12. for performing this check instead of requiring every application
  13. to implement the check separately.
  14. This backport brings ``match_hostname()`` to users
  15. of earlier versions of Python.
  16. Simply make this distribution a dependency of your package,
  17. and then use it like this::
  18. from backports.ssl_match_hostname import match_hostname, CertificateError
  19. ...
  20. sslsock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_SSLv3,
  21. cert_reqs=ssl.CERT_REQUIRED, ca_certs=...)
  22. try:
  23. match_hostname(sslsock.getpeercert(), hostname)
  24. except CertificateError, ce:
  25. ...
  26. Note that the ``ssl`` module is only included in the Standard Library
  27. for Python 2.6 and later;
  28. users of Python 2.5 or earlier versions
  29. will also need to install the ``ssl`` distribution
  30. from the Python Package Index to use code like that shown above.
  31. Brandon Craig Rhodes is merely the packager of this distribution;
  32. the actual code inside comes verbatim from Python 3.4.
  33. History
  34. -------
  35. * This function was introduced in python-3.2
  36. * It was updated for python-3.4a1 for a CVE
  37. (backports-ssl_match_hostname-3.4.0.1)
  38. * It was updated from RFC2818 to RFC 6125 compliance in order to fix another
  39. security flaw for python-3.3.3 and python-3.4a5
  40. (backports-ssl_match_hostname-3.4.0.2)
  41. .. _RFC2818: http://tools.ietf.org/html/rfc2818.html