summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-05-15 02:31:21 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-05-15 02:31:21 +0000
commitcdada6ee08efc6b03038d2f894b272c9a7b2d007 (patch)
tree89c767c638a700828891a8af2e96700952f4255e /src/lib
parentfdeff2738de860e8d860adf457f06b3d81c97e4e (diff)
downloadbcfg2-cdada6ee08efc6b03038d2f894b272c9a7b2d007.tar.gz
bcfg2-cdada6ee08efc6b03038d2f894b272c9a7b2d007.tar.bz2
bcfg2-cdada6ee08efc6b03038d2f894b272c9a7b2d007.zip
Add explicit key parsing error (Resolves Ticket #439)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3178 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-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