Index: trunk/packages/sipb-xen-vnc-server/code/vncexternalauth.py
===================================================================
--- trunk/packages/sipb-xen-vnc-server/code/vncexternalauth.py	(revision 286)
+++ trunk/packages/sipb-xen-vnc-server/code/vncexternalauth.py	(revision 288)
@@ -46,8 +46,9 @@
 
     def dataReceived(self,data):
+        #self.socks.log(self,"R"+data)
         self.socks.write(data)
 
     def write(self,data):
-        #self.socks.log(self,data)
+        #self.socks.log(self,'W'+data)
         self.transport.write(data)
 
@@ -66,4 +67,5 @@
     def validateToken(self, token):
         global TOKEN_KEY
+        self.auth_error = "Invalid token"
         try:
             token = base64.urlsafe_b64decode(token)
@@ -71,5 +73,4 @@
             m = hmac.new(TOKEN_KEY, digestmod=sha)
             m.update(token['data'])
-            self.auth_error = "Invalid token"
             if (m.digest() == token['digest']):
                 data = cPickle.loads(token['data'])
@@ -82,6 +83,6 @@
                 else:
                     self.auth_error = "Token has expired; please try logging in again"
-        except:
-            self.auth = None
+        except (TypeError, cPickle.UnpicklingError):
+            self.auth = None            
             print sys.exc_info()
 
@@ -100,5 +101,5 @@
                     (header, data) = line.split(": ", 1)
                     headers[header] = data
-                except:
+                except ValueError:
                     pass
 
@@ -115,22 +116,20 @@
                 if ("Auth-token" in headers):
                     token = headers["Auth-token"]
-                    try:
-                        self.validateToken(token)
-                    finally:
-                        if self.auth is not None:
-                            port = getPort(vmname, self.auth_data)
-                            if port is not None: # FIXME
-                                if port is not 0:
-                                    d = self.connectClass(self.server, port, VNCAuthOutgoing, self)
-                                    d.addErrback(lambda result, self=self: self.makeReply(404, result.getErrorMessage()))
-                                else:
-                                    self.makeReply(404, "Unable to find VNC for VM "+vmname)
+                    self.validateToken(token)
+                    if self.auth is not None:
+                        port = getPort(vmname, self.auth_data)
+                        if port is not None: # FIXME
+                            if port != 0:
+                                d = self.connectClass(self.server, port, VNCAuthOutgoing, self)
+                                d.addErrback(lambda result, self=self: self.makeReply(404, result.getErrorMessage()))
                             else:
-                                self.makeReply(401, "Unauthorized to connect to VM "+vmname)
+                                self.makeReply(404, "Unable to find VNC for VM "+vmname)
                         else:
-                            if self.auth_error:
-                                self.makeReply(401, self.auth_error)
-                            else:
-                                self.makeReply(401, "Invalid token")
+                            self.makeReply(401, "Unauthorized to connect to VM "+vmname)
+                    else:
+                        if self.auth_error:
+                            self.makeReply(401, self.auth_error)
+                        else:
+                            self.makeReply(401, "Invalid token")
                 else:
                     self.makeReply(401, "Login first")
Index: trunk/packages/sipb-xen-vnc-server/code/vncproxy.py
===================================================================
--- trunk/packages/sipb-xen-vnc-server/code/vncproxy.py	(revision 286)
+++ trunk/packages/sipb-xen-vnc-server/code/vncproxy.py	(revision 288)
@@ -1,7 +1,13 @@
 #! /usr/bin/python
-from twisted.internet import reactor
+from twisted.internet import reactor, ssl
 import vncexternalauth
 
+sslContext = ssl.DefaultOpenSSLContextFactory(
+	'vncproxykey.pem',
+	'vncproxy.crt',
+)
+
 if '__main__' == __name__:
-    reactor.listenTCP(10003,vncexternalauth.VNCAuthFactory("./vncauth.log", "localhost"))
+    reactor.listenSSL(10003,vncexternalauth.VNCAuthFactory("./vncauth.log", "localhost"), contextFactory=sslContext)
+    #reactor.listenTCP(10003,vncexternalauth.VNCAuthFactory("./vncauth.log", "localhost"))
     reactor.run()
Index: trunk/packages/sipb-xen-vnc-server/debian/control
===================================================================
--- trunk/packages/sipb-xen-vnc-server/debian/control	(revision 286)
+++ trunk/packages/sipb-xen-vnc-server/debian/control	(revision 288)
@@ -6,5 +6,5 @@
 Standards-Version: 3.7.2
 
-Package: sipb-xen-dhcp
+Package: sipb-xen-vnc-server
 Architecture: all
 Depends: ${misc:Depends}, daemon, python-twisted-core, xen-utils-3.1-1
Index: trunk/packages/sipb-xen-vnc-server/debian/sipb-xen-vnc-server.init
===================================================================
--- trunk/packages/sipb-xen-vnc-server/debian/sipb-xen-vnc-server.init	(revision 286)
+++ trunk/packages/sipb-xen-vnc-server/debian/sipb-xen-vnc-server.init	(revision 288)
@@ -46,5 +46,5 @@
 	#   2 if daemon could not be started
 	daemon --running -n $NAME && return 1
-	daemon -r -D "$(dirname $DAEMON)" -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2
+	daemon -r -U -O daemon.info -E daemon.err -n $NAME -U $DAEMON $DAEMON_ARGS || return 2
 }
 
