1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Added server.py ssl mode dependant on cert existence

This commit is contained in:
Michael 2014-09-02 22:33:45 -06:00
parent bcf0aae531
commit a95cc678e9
2 changed files with 24 additions and 5 deletions

View File

@ -47,6 +47,7 @@ fail_if_error() {
}
}
mkdir -p $DST_DIR
fail_if_error $?
cd $DST_DIR

View File

@ -33,6 +33,7 @@ import tornado.ioloop
import tornado.web
import tornado.autoreload
import pkg_resources
from os.path import expanduser
from pkg_resources import parse_version
from .config import Config
@ -136,6 +137,24 @@ class Server(object):
JSONRPCWebSocket.register_destination(destination, instance.name)
instance.start() # starts the new process
def _get_cert_info(self):
"""
Finds the cert and key file needed for SSL
"""
home = expanduser("~")
ssl_dir = "%s/.conf/GNS3Certs/" % (home)
log.debug("Looking for SSL certs in: %s" % (ssl_dir))
keyfile = "%s/gns3server.localdomain.com.key" % (ssl_dir)
certfile = "%s/gns3server.localdomain.com.crt" % (ssl_dir)
if os.path.isfile(keyfile) and os.path.isfile(certfile):
return { "certfile" : certfile,
"keyfile" : keyfile,
}
def run(self):
"""
Starts the Tornado web server and ZeroMQ server.
@ -160,12 +179,11 @@ class Server(object):
zmq.zmq_version()))
kwargs = {"address": self._host}
ssl_options={
"certfile": "/home/michaelgale/nas/workspace/gns3-server/gns3server/certs/gns3server.localdomain.com.crt",
"keyfile": "/home/michaelgale/nas/workspace/gns3-server/gns3server/certs/gns3server.localdomain.com.key",
}
ssl_options = self._get_cert_info()
kwargs['ssl_options'] = ssl_options
if ssl_options:
log.info("Certs found - starting in SSL mode")
kwargs['ssl_options'] = ssl_options
if parse_version(tornado.version) >= parse_version("3.1"):
kwargs["max_buffer_size"] = 524288000 # 500 MB file upload limit