~landscape/zope3/ztk-1.1.3

« back to all changes in this revision

Viewing changes to src/twisted/test/ssl_helpers.py

  • Committer: Andreas Hasenack
  • Date: 2009-07-20 17:49:16 UTC
  • Revision ID: andreas@canonical.com-20090720174916-g2tn6qmietz2hn0u
Revert twisted removal, it breaks several dozen tests [trivial]

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
 
 
6
from twisted.internet import ssl
 
7
from twisted.python.util import sibpath
 
8
 
 
9
from OpenSSL import SSL
 
10
 
 
11
class ClientTLSContext(ssl.ClientContextFactory):
 
12
    isClient = 1
 
13
    def getContext(self):
 
14
        return SSL.Context(SSL.TLSv1_METHOD)
 
15
 
 
16
class ServerTLSContext:
 
17
    isClient = 0
 
18
    
 
19
    def __init__(self, filename = sibpath(__file__, 'server.pem')):
 
20
        self.filename = filename
 
21
 
 
22
    def getContext(self):
 
23
        ctx = SSL.Context(SSL.TLSv1_METHOD)
 
24
        ctx.use_certificate_file(self.filename)
 
25
        ctx.use_privatekey_file(self.filename)
 
26
        return ctx