Skip to content

Instantly share code, notes, and snippets.

@glyph
Created March 17, 2014 21:53
Show Gist options
  • Save glyph/9609180 to your computer and use it in GitHub Desktop.
Save glyph/9609180 to your computer and use it in GitHub Desktop.
created by github.com/tr3buchet/gister
"""
This module implements Transport Layer Security (TLS) support for Twisted. It
requires U{PyOpenSSL <https://pypi.python.org/pypi/pyOpenSSL>}.
If you wish to establish a TLS connection, please use one of the following
APIs:
- SSL endpoints for L{servers
<twisted.internet.endpoints.SSL4ServerEndpoint>} and L{clients
<twisted.internet.endpoints.SSL4ClientEndpoint>}
- L{startTLS <twisted.internet.interfaces.ITLSTransport.startTLS>}
- L{connectSSL <twisted.internet.interfaces.IReactorSSL.connectSSL>}
- L{listenSSL <twisted.internet.interfaces.IReactorSSL.listenSSL>}
These APIs all require C{contextFactory} argument that specifies their security
properties, such as certificate, private key, certificate authorities to verify
the peer, allowed TLS protocol versions, cipher suites, and so on. The
recommended value for this argument is a L{CertificateOptions} instance; see
its documentation for an explanation of the available options.
In this module you will also find the base classes for implementing your own
context factories. However, be warned that implementing your own context
factory is both difficult and dangerous; the Twisted team has worked hard to
make L{CertificateOptions}' comprehensible and unsurprising, and the Twisted
team is actively maintaining it to ensure that it becomes more secure over
time. If you are really absolutely sure that you want to take on the risk of
implementing your own context factory based on the pyOpenSSL API, server
context factories may inherit from L{ContextFactory}, and client context
factories may inherit from L{ClientContextFactory}.
Developers using Twisted, please ignore the L{Port}, L{Connector}, and
L{Client} classes defined here, as these are details of certain reactors' TLS
implementations, exposed by accident (and remaining here only for compatibility
reasons). If you wish to establish a TLS connection, please use one of the
APIs listed above.
@note: "SSL" (Secure Sockets Layer) is an antiquated synonym for "TLS"
(Transport Layer Security). You may see these terms used interchangeably
throughout the documentation.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment