How to use the cheroot.ssl.builtin.BuiltinSSLAdapter function in cheroot

To help you get started, we’ve selected a few cheroot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nbeguier / cassh / src / server / server.py View on Github external
is_auth, message = tools.ldap_authentification(SERVER_OPTS)
        if not is_auth:
            return tools.response_render(message, http_code='401 Unauthorized')
        return tools.response_render('OK')

class MyApplication(web.application):
    """
    Can change port or other stuff
    """
    def run(self, port=int(SERVER_OPTS['port']), *middleware):
        func = self.wsgifunc(*middleware)
        return web.httpserver.runsimple(func, ('0.0.0.0', port))

if __name__ == "__main__":
    if SERVER_OPTS['ssl']:
        HTTPServer.ssl_adapter = BuiltinSSLAdapter(
            certificate=SERVER_OPTS['ssl_public_key'],
            private_key=SERVER_OPTS['ssl_private_key'])
    if ARGS.verbose:
        print('SSL: %s' % SERVER_OPTS['ssl'])
        print('LDAP: %s' % SERVER_OPTS['ldap'])
        print('Admin DB Failover: %s' % SERVER_OPTS['admin_db_failover'])
    APP = MyApplication(constants.URLS, globals(), autoreload=False)
    web.config.debug = SERVER_OPTS['debug']
    if SERVER_OPTS['debug']:
        print('Debug mode on')
    APP.run()
github Dan-in-CA / SIP / sip.py View on Github external
except Exception:
        pass
    _thread.start_new_thread(timing_loop, ())

    if gv.use_gpio_pins:
        set_output()

    app.notfound = lambda: web.seeother(u"/")
    
    ###########################
    #### For HTTPS (SSL):  ####

    if gv.sd["htp"] == 443:
        from cheroot.server import HTTPServer
        from cheroot.ssl.builtin import BuiltinSSLAdapter   
        HTTPServer.ssl_adapter = BuiltinSSLAdapter(
            certificate='/usr/lib/ssl/certs/SIP.crt',
            private_key='/usr/lib/ssl/private/SIP.key'
        )

    app.run()
github cherrypy / cheroot / cheroot / ssl / builtin.py View on Github external
def __init__(
            self, certificate, private_key, certificate_chain=None,
            ciphers=None):
        """Set up context in addition to base class properties if available."""
        if ssl is None:
            raise ImportError('You must install the ssl module to use HTTPS.')

        super(BuiltinSSLAdapter, self).__init__(
            certificate, private_key, certificate_chain, ciphers)

        self.context = ssl.create_default_context(
            purpose=ssl.Purpose.CLIENT_AUTH,
            cafile=certificate_chain
        )
        self.context.load_cert_chain(certificate, private_key)
        if self.ciphers is not None:
            self.context.set_ciphers(ciphers)
github cherrypy / cheroot / cheroot / ssl / builtin.py View on Github external
def bind(self, sock):
        """Wrap and return the given socket."""
        return super(BuiltinSSLAdapter, self).bind(sock)
github gilestrolab / ethoscope / src / scripts / device_server.py View on Github external
def run(self, handler): # pragma: no cover
        from cheroot import wsgi
        from cheroot.ssl import builtin
        self.options['bind_addr'] = (self.host, self.port)
        self.options['wsgi_app'] = handler
        certfile = self.options.pop('certfile', None)
        keyfile = self.options.pop('keyfile', None)
        chainfile = self.options.pop('chainfile', None)
        server = wsgi.Server(**self.options)
        if certfile and keyfile:
            server.ssl_adapter = builtin.BuiltinSSLAdapter(
                    certfile, keyfile, chainfile)
        try:
            server.start()
        finally:
            server.stop()
#############
github gilestrolab / ethoscope / node_src / scripts / server.py View on Github external
def run(self, handler): # pragma: no cover
        from cheroot import wsgi
        from cheroot.ssl import builtin
        self.options['bind_addr'] = (self.host, self.port)
        self.options['wsgi_app'] = handler
        certfile = self.options.pop('certfile', None)
        keyfile = self.options.pop('keyfile', None)
        chainfile = self.options.pop('chainfile', None)
        server = wsgi.Server(**self.options)
        if certfile and keyfile:
            server.ssl_adapter = builtin.BuiltinSSLAdapter(
                    certfile, keyfile, chainfile)
        try:
            server.start()
        finally:
            server.stop()
#############
github jheld / diycrate / server_app.py View on Github external
def run(self, server_handler):
        """
        Overrides super to setup Cherry py with ssl and start the server.
        :param server_handler: originating server type
        :type server_handler:
        """
        server = Server((self.host, self.port), server_handler)
        # Uses the following github page's recommendation for setting up the cert:
        # https://github.com/nickbabcock/bottle-ssl
        server.ssl_adapter = BuiltinSSLAdapter(conf_obj['ssl']['cacert_pem_path'],
                                               conf_obj['ssl']['privkey_pem_path'],
                                               conf_obj['ssl'].get('chain_pem_path'))
        try:
            server.start()
        finally:
            server.stop()
github ralphwetzel / theonionbox / theonionbox / tob / box.py View on Github external
def run(self, handler):  # pragma: no cover
                from cheroot import wsgi
                from cheroot.ssl import builtin
                self.options['bind_addr'] = (self.host, self.port)
                self.options['wsgi_app'] = handler
                certfile = self.options.pop('certfile', None)
                keyfile = self.options.pop('keyfile', None)
                chainfile = self.options.pop('chainfile', None)
                self.server = wsgi.Server(**self.options)
                if certfile and keyfile:
                    self.server.ssl_adapter = builtin.BuiltinSSLAdapter(
                        certfile, keyfile, chainfile)

                self.server.start()