changeset 745:7697385bbb7f

pep 8 style changes to SecureThreadPoolServer
author mgilbert@MGILBERT.na.qualcomm.com
date Mon, 05 Jun 2006 17:52:35 +0200
parents 9595eaf676a7
children 0d3e9b79dde3 bcdfbb11da9f
files MoinMoin/server/standalone.py docs/CHANGES
diffstat 2 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/server/standalone.py	Mon Jun 05 11:00:18 2006 +0200
+++ b/MoinMoin/server/standalone.py	Mon Jun 05 17:52:35 2006 +0200
@@ -403,7 +403,7 @@
                         self.request.getsockname()[1])
                 path = '/'
                 
-            self.requestline = 'ERROR: Redirecting to https://%s/%s' % (host, path)
+            self.requestline = 'ERROR: Redirecting to https://%s%s' % (host, path)
             self.request_version = 'HTTP/1.1'
             self.command = 'GET'
             self.send_response(301, 'Document Moved')
@@ -417,12 +417,12 @@
         def __init__(self, config):
             ThreadPoolServer.__init__(self, config)
             
-            cert = open(config.certificatePath).read()
+            cert = open(config.ssl_certificate).read()
             x509 = X509()
             x509.parse(cert)
             self.certChain = X509CertChain([x509])
             
-            priv = open(config.privateKeyPath).read()
+            priv = open(config.ssl_privkey).read()
             self.privateKey = parsePEMKey(priv, private=True)
             
             self.sessionCache = SessionCache()
@@ -430,24 +430,25 @@
         def finish_request(self, sock, client_address):
             # Peek into the packet, if it starts with GET or POS(T) then
             # redirect, otherwise let TLSLite handle the connection.
-            peek = sock.recv(3, socket.MSG_PEEK)
-            if peek.lower() == 'get' or peek.lower() == 'pos':
-                response = SecureRequestRedirect(sock, client_address, self)
-            tlsConnection = TLSConnection(sock)
-            if self.handshake(tlsConnection) == True:
-                self.RequestHandlerClass(tlsConnection, client_address, self)
+            peek = sock.recv(3, socket.MSG_PEEK).lower()
+            if peek == 'get' or peek == 'pos':
+                SecureRequestRedirect(sock, client_address, self)
+                return
+            tls_connection = TLSConnection(sock)
+            if self.handshake(tls_connection) == True:
+                self.RequestHandlerClass(tls_connection, client_address, self)
             else:
                 # This will probably fail because the TLSConnection has 
                 # already written SSL stuff to the socket. But not sure what
                 # else we should do.
-                response = SecureRequestRedirect(sock, client_address, self)
+                SecureRequestRedirect(sock, client_address, self)
                 
-        def handshake(self, tlsConnection):
+        def handshake(self, tls_connection):
             try:
-                tlsConnection.handshakeServer(certChain = self.certChain,
-                        privateKey = self.privateKey,
-                        sessionCache = self.sessionCache)
-                tlsConnection.ignoreAbruptClose = True
+                tls_connection.handshakeServer(certChain = self.certChain,
+                                               privateKey = self.privateKey,
+                                               sessionCache = self.sessionCache)
+                tls_connection.ignoreAbruptClose = True
                 return True
             except:
                 return False
--- a/docs/CHANGES	Mon Jun 05 11:00:18 2006 +0200
+++ b/docs/CHANGES	Mon Jun 05 17:52:35 2006 +0200
@@ -79,6 +79,9 @@
       You need to set "cache_dir = '/some/farm/cachedir' in your farmconfig.
     * Added XMLRPC methods for attachment handling. Thanks to Matthew Gilbert.
     * Added TLS/SSL support to the standalone server. Thanks to Matthew Gilbert.
+      To use TLS/SSL support you must also install the TLSLite library
+      (http://trevp.net/tlslite/). Version 0.3.8 was used for development and
+      testing.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page