summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Component.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/Server/Component.py b/src/lib/Server/Component.py
index 95f65a476..34dfbddc2 100644
--- a/src/lib/Server/Component.py
+++ b/src/lib/Server/Component.py
@@ -15,6 +15,10 @@ class ComponentInitError(Exception):
'''Raised in case of component initialization failure'''
pass
+class ComponentKeyError(Exception):
+ '''raised in case of key parse fails'''
+ pass
+
class CobaltXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
'''CobaltXMLRPCRequestHandler takes care of ssl xmlrpc requests'''
def finish(self):
@@ -61,7 +65,10 @@ class TLSServer(Bcfg2.tlslite.api.TLSSocketServerMixIn,
x509 = Bcfg2.tlslite.api.X509()
s = open(keyfile).read()
x509.parse(s)
- self.key = Bcfg2.tlslite.api.parsePEMKey(s, private=True)
+ try:
+ self.key = Bcfg2.tlslite.api.parsePEMKey(s, private=True)
+ except:
+ raise ComponentKeyError
self.chain = Bcfg2.tlslite.api.X509CertChain([x509])
BaseHTTPServer.HTTPServer.__init__(self, address, handler)
@@ -132,6 +139,9 @@ class Component(TLSServer,
except socket.error:
self.logger.error("Failed to bind to socket")
raise ComponentInitError
+ except ComponentKeyError:
+ self.logger.error("Failed to parse key" % (keyfile))
+ raise ComponentInitError
except:
self.logger.error("Failed to load ssl key %s" % (keyfile), exc_info=1)
raise ComponentInitError