Created
January 15, 2013 15:59
-
-
Save hynek/4539676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from OpenSSL import SSL | |
from twisted.internet import ssl | |
class TLSContextWithChainFileFactory(ssl.DefaultOpenSSLContextFactory): | |
""" | |
A SSLContext factory for TLS only and C{certificateFileName} is set as the | |
chain file. Add all chain files that lead from the CA to your certificate. | |
""" | |
def cacheContext(self): | |
if self._context is None: | |
ctx = SSL.Context(SSL.TLSv1_METHOD) | |
ctx.use_certificate_chain_file(self.certificateFileName) | |
ctx.use_privatekey_file(self.privateKeyFileName) | |
self._context = ctx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment