Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super(HTTPSProcess, self).__init__(*args, **kwargs)

        proxy_url = 'http://' + self.cfg['proxy_ip'] + ':' + str(
            self.cfg['proxy_port'])

        http_proxy_factory = HTTPStreamFactory(proxy_url)

        cv = ChainValidator()
        ok, err = cv.validate(self.cfg,
                              must_be_disabled=False,
                              check_expiration=False)
        if not ok or not err is None:
            raise err

        snimap = SNIMap({
            'DEFAULT':
            TLSServerContextFactory(self.cfg['ssl_key'], self.cfg['ssl_cert'],
                                    self.cfg['ssl_intermediate'],
                                    self.cfg['ssl_dh'])
        })

        socket_fds = self.cfg['tls_socket_fds']

        for socket_fd in socket_fds:
            self.log("Opening socket: %d : %s" %
                     (socket_fd, os.fstat(socket_fd)))

            port = listen_tls_on_sock(reactor,
                                      fd=socket_fd,
                                      contextFactory=snimap,
                                      factory=http_proxy_factory)

            self.ports.append(port)
            self.log("HTTPS proxy listening on %s" % port)
Exemplo n.º 2
0
    def load(self, tid, conf):
        chnv = ChainValidator()
        ok, err = chnv.validate(conf, must_be_disabled=False, check_expiration=False)
        if not ok or err is not None:
            return

        self.configs_by_tid[tid] = conf

        context = TLSServerContextFactory(conf['ssl_key'],
                                          conf['ssl_cert'],
                                          conf['ssl_intermediate'])

        self.contexts_by_hostname[conf['hostname']] = context

        if tid == 1:
            self.set_default_context(context.getContext())
Exemplo n.º 3
0
def make_TLSContextFactory(site_cfg):
    return TLSServerContextFactory(site_cfg['ssl_key'], site_cfg['ssl_cert'],
                                   site_cfg['ssl_intermediate'],
                                   site_cfg['ssl_dh'])