From 218ae6183656698b12dfbe3d306c9b29bfe11a14 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 31 May 2011 19:31:49 +0000 Subject: [PATCH] Add the same error-checking used for SSH to SSL keyfile generation. --- src/server/ssl.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/server/ssl.py b/src/server/ssl.py index 205e49b0a..5927947fd 100644 --- a/src/server/ssl.py +++ b/src/server/ssl.py @@ -33,14 +33,19 @@ def verify_SSL_key_and_cert(keyfile, certfile): from Crypto.PublicKey import RSA from twisted.conch.ssh.keys import Key - print " Creating SSL key and certificate (this need only be done once)." - - # create the RSA key and store it. - KEY_LENGTH = 1024 - rsaKey = Key(RSA.generate(KEY_LENGTH)) - keyString = rsaKey.toString(type="OPENSSH") - file(keyfile, 'w+b').write(keyString) + print " Creating SSL key and certificate ... ", + try: + # create the RSA key and store it. + KEY_LENGTH = 1024 + rsaKey = Key(RSA.generate(KEY_LENGTH)) + keyString = rsaKey.toString(type="OPENSSH") + file(keyfile, 'w+b').write(keyString) + except Exception,e: + print "rsaKey error: %s\n WARNING: Evennia could not auto-generate SSL private key." % e + print "If this error persists, create game/%s yourself using third-party tools." % keyfile + sys.exit() + # try to create the certificate CERT_EXPIRE = 365 * 20 # twenty years validity # default: @@ -57,6 +62,7 @@ def verify_SSL_key_and_cert(keyfile, certfile): print " Example (linux, using the openssl program): " print " %s" % exestring sys.exit() + print "done." def getSSLContext(): """