Subversion Repositories dev


Rev 15985 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

# -*- coding: utf-8 -*-
# Copyright 2013 Univention GmbH
# All rights reserved.
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <>.

import sys

from twisted.web.server import Site
from twisted.application import internet, service
from OpenSSL import SSL
from univention.multimaster.utils import getReplicationServicePort, LOCAL_FQDN
from univention.multimaster.sync import initialSync
from univention.multimaster.web import Home
from univention.multimaster.auditlog import startListening
from twisted.python.log import ILogObserver

from univention.multimaster.logging import logObserver

# SSL code snipplets taken from:

class ServerContextFactory(object):
        def getContext(self):
                """Create an SSL context.

                This is a sample implementation that loads a certificate from a file
                called 'server.pem'."""
                ctx = SSL.Context(SSL.SSLv23_METHOD)
                ctx.use_certificate_file('/etc/univention/ssl/%s/cert.pem' % LOCAL_FQDN)
                ctx.use_privatekey_file('/etc/univention/ssl/%s/private.key' % LOCAL_FQDN)
                return ctx

application = service.Application("multi-master-replication")
application.setComponent(ILogObserver, logObserver.emit)
mmrService = internet.SSLServer(getReplicationServicePort(), Site(Home()), ServerContextFactory())