diff --git a/nagixsc_conf2http.py b/nagixsc_conf2http.py
index 640539fc98013311286c65ead7f022575501e282..d296bfff07bd2ca70da64fdd8e5ef3a1bbbccf2b 100755 (executable)
--- a/nagixsc_conf2http.py
+++ b/nagixsc_conf2http.py
#!/usr/bin/python
-import BaseHTTPServer
import ConfigParser
import base64
import optparse
try:
config['ip'] = cfgread.get('server', 'ip')
config['port'] = cfgread.getint('server', 'port')
+ config['ssl'] = cfgread.getboolean('server', 'ssl')
+ config['cert'] = cfgread.get('server', 'sslcert')
config['conf_dir'] = cfgread.get('server', 'conf_dir')
- config['conf2xml_cmdline'] = cfgread.get('server', 'conf2xml_cmdline')
except ConfigParser.NoOptionError, e:
print 'Config file error: %s ' % e
##############################################################################
-class Conf2HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+class Conf2HTTPHandler(MyHTTPRequestHandler):
def http_error(self, code, output):
self.send_response(code)
def do_GET(self):
- cmdline = config['conf2xml_cmdline']
-
path = self.path.split('/')
# Check Basic Auth
def main():
+ if config['ssl'] and not os.path.isfile(config['cert']):
+ print 'SSL certificate "%s" not found!' % config['cert']
+ sys.exit(127)
+
+ server = MyHTTPServer((config['ip'], config['port']), Conf2HTTPHandler, ssl=config['ssl'], sslpemfile=config['cert'])
try:
- server = BaseHTTPServer.HTTPServer((config['ip'], config['port']), Conf2HTTPHandler)
server.serve_forever()
except:
server.socket.close()