From ee573b48169af89ed2be98ee97edd7bd3fc572c4 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 3 Aug 2009 21:39:06 +0000 Subject: [PATCH] Add a check_ssl_keys() function that will check for the keys and generate them if needed --- deluge/core/rpcserver.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 7baaf2930..a7b8f4e60 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -329,17 +329,8 @@ class RPCServer(component.Component): log.info("Starting DelugeRPC server %s:%s", hostname, port) - # Check for SSL cert/key and create them if necessary - ssl_dir = deluge.configmanager.get_config_dir("ssl") - if not os.path.exists(ssl_dir): - # The ssl folder doesn't exist so we need to create it - os.makedirs(ssl_dir) - generate_ssl_keys() - else: - for f in ("daemon.pkey", "daemon.cert"): - if not os.path.exists(os.path.join(ssl_dir, f)): - generate_ssl_keys() - break + + check_ssl_keys() try: reactor.listenSSL(port, self.factory, ServerContextFactory(), interface=hostname) @@ -403,6 +394,19 @@ class RPCServer(component.Component): (RPC_EVENT, event.name, event.args) ) +def check_ssl_keys(): + # Check for SSL cert/key and create them if necessary + ssl_dir = deluge.configmanager.get_config_dir("ssl") + if not os.path.exists(ssl_dir): + # The ssl folder doesn't exist so we need to create it + os.makedirs(ssl_dir) + generate_ssl_keys() + else: + for f in ("daemon.pkey", "daemon.cert"): + if not os.path.exists(os.path.join(ssl_dir, f)): + generate_ssl_keys() + break + def generate_ssl_keys(): """ This method generates a new SSL key/cert.