当前位置: 首页>>代码示例>>Python>>正文


Python CherryPyWSGIServer.ssl_adapter方法代码示例

本文整理汇总了Python中cherrypy.wsgiserver.CherryPyWSGIServer.ssl_adapter方法的典型用法代码示例。如果您正苦于以下问题:Python CherryPyWSGIServer.ssl_adapter方法的具体用法?Python CherryPyWSGIServer.ssl_adapter怎么用?Python CherryPyWSGIServer.ssl_adapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cherrypy.wsgiserver.CherryPyWSGIServer的用法示例。


在下文中一共展示了CherryPyWSGIServer.ssl_adapter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inner_run

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
        def inner_run():
            if ssl_private_key and ssl_certificate:
                print "MSS server is running at https://%s:%s/" % (addr, port)
            else:
                print "MSS server is running at http://%s:%s/" % (addr, port)
            if settings.DEBUG:
                print "Devel mode is ON"
                print "Quit the server with %s." % quit_command

            app = WSGIHandler()
            path = {}
            if show_log:
                logged_app = TransLogger(app)
                path['/'] = logged_app
            else:
                path['/'] = app
            path[settings.MEDIA_URL] = MediaHandler(settings.MEDIA_ROOT)
            dispatcher = WSGIPathInfoDispatcher(path)
            server = CherryPyWSGIServer((addr, int(port)), dispatcher, threads)

            if ssl_private_key and ssl_certificate:
                from cherrypy.wsgiserver.ssl_pyopenssl import pyOpenSSLAdapter
                server.ssl_adapter = pyOpenSSLAdapter(ssl_certificate, ssl_private_key, None)

            try:
                server.start()
            except KeyboardInterrupt:
                server.stop()
                sys.exit(0)
开发者ID:figarocorso,项目名称:mss,代码行数:31,代码来源:runmss.py

示例2: run

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
 def run(self, handler):
     server = CherryPyWSGIServer((self.host, self.port), handler)
     server.ssl_adapter = pyOpenSSLAdapter(CONSTANTS['certificate'], CONSTANTS['key'])
     try:
         server.start()
     finally:
         server.stop()
开发者ID:armedTiger,项目名称:openbmc,代码行数:9,代码来源:rest.py

示例3: run

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
    def run(self, handler):
        self.options['bind_addr'] = (self.host, self.port)
        self.options['wsgi_app'] = handler

        certfile = self.options.get('certfile')
        if certfile or 'certfile' in self.options:
            del self.options['certfile']
        keyfile = self.options.get('keyfile')
        if keyfile or 'keyfile' in self.options:
            del self.options['keyfile']

        server = CherryPyWSGIServer(**self.options)
        if keyfile and certfile:
            LOGGER.info("Start using HTTPS")
            server.ssl_adapter = pyOpenSSLAdapter(certfile, keyfile, None)
            context = ssl.Context(ssl.SSLv23_METHOD)
            context.set_cipher_list('HIGH')
            context.use_privatekey_file(keyfile)
            context.use_certificate_file(certfile)
            server.ssl_adapter.context = context
        else:
            LOGGER.info("Start using HTTP")

        try:
            server.start()
        finally:
            server.stop()
开发者ID:diateam,项目名称:proxyvor-target,代码行数:29,代码来源:server.py

示例4: run

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
 def run(self, handler):
     server = CherryPyWSGIServer((self.host, self.port), handler)
     server.ssl_adapter = \
             pyOpenSSLAdapter(RestConfig.get('ssl','certificate'),
                              RestConfig.get('ssl', 'key'))
     try:
         server.start()
     finally:
         server.stop()
开发者ID:HengWang,项目名称:openbmc,代码行数:11,代码来源:rest.py

示例5: run

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
    def run(self, handler):
        server = CherryPyWSGIServer((self.host, self.port), handler, server_name='localhost')
        """
        openssl genrsa -out privkey.pem 1024
        openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
        """
        crt = '/etc/coinbend/cacert.pem'
        key = '/etc/coinbend/privkey.pem'
        #ca  = '/etc/ssl/intermediate.crt'
        server.ssl_module  = "pyopenssl"
        server.ssl_adapter = PatchBuiltinSSLAdapter(crt, key)

        # fucking p.o.s. cherry does NOT support prebuilt ssl contexts
        #server.ssl_adapter.context = sc

        try:
            server.start()
        finally:
            server.stop()
开发者ID:robertsdotpm,项目名称:coinbend,代码行数:21,代码来源:api.py

示例6: check_file

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
        check_file('PARTNER_PRIVATE_KEY', PARTNER_PRIVATE_KEY)
        check_string('HFPP_PARTNER_ID',HFPP_PARTNER_ID)
        check_port('PARTNER_CLIENT_HTTP_SERVICE_PORT',PARTNER_CLIENT_HTTP_SERVICE_PORT)
        check_bool('PARTNER_IMMEDIATE_FULLFIL', PARTNER_IMMEDIATE_FULLFIL)
        check_string('DECISION_MODULE_URL', DECISION_MODULE_URL)
        check_file('STUDY_REPORT_DIRECTORY', STUDY_REPORT_DIRECTORY)
        #badly formed hexadecimal UUID string will throw if not uuid string
        partner_id = uuid.UUID(HFPP_PARTNER_ID)
        logging.debug('hfpp partner id:%s',partner_id)
    except (TypeError,ValueError) as e:
        method_error(signature, e)
        sys.exit(-1)
    conf = {'global': {
            'request.error_response' : handle_error
        }
    }
    #configure cherrypy
    cherrypy.config.update(conf)
    
    wsgi_app = cherrypy.Application(PartnerHTTPServices(), '/callbacks')
    dispatcher = WSGIPathInfoDispatcher({'/': wsgi_app})
    server = CherryPyWSGIServer(('0.0.0.0', PARTNER_CLIENT_HTTP_SERVICE_PORT), dispatcher)
    sslAdapter = BuiltinSSLAdapter(PARTNER_CERTIFICATE, PARTNER_PRIVATE_KEY)
    server.ssl_adapter = sslAdapter
    try:
        server.start()
    except KeyboardInterrupt:
        server.stop()
    method_exit(signature)

开发者ID:B-Rich,项目名称:CoECI-CMS-Healthcare-Fraud-Prevention,代码行数:31,代码来源:partnercli.py

示例7: start_server_servestatic

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
    def start_server_servestatic(self, options):
        """
        Start CherryPy server AND serve default static files

        Want SSL support?
        a. The new (3.1 or 3.2) way: Just set server.ssl_adapter to an SSLAdapter instance.
        b. The old way (deprecated way) is to set these attributes:

           server.ssl_certificate = <filename>
           server.ssl_private_key = <filename>

           But this is the only way from the management command line
           in the future I may need to adapt this to use a server.ssl_adapter

        """
        # debug?
        # print "options:"
        from django.conf import settings
        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'

        self.stdout.write("Validating models..")
        self.validate(display_num_errors=True)
        self.stdout.write((
            "%(started_at)s\n"
            "Django version %(version)s, using settings %(settings)r\n"
            "cherrypy django_wsgiserver is running at http://%(addr)s:%(port)s/\n"
            "Quit the server with %(quit_command)s.\n"
        ) % {
            "started_at": datetime.now().strftime('%B %d, %Y - %X'),
            "version": self.get_version(),
            "settings": settings.SETTINGS_MODULE,
            "addr": options['host'],  # self._raw_ipv6 and '[%s]' % self.addr or self.addr,
            "port": options['port'],
            "quit_command": quit_command,
        })

        #logger.info("launching wsgiserver with the following options")
        # logger.info(pformat(options))
        if int(options['verbose']) >= 2:
            self.stdout.write("launching with the following options:\n")
            self.stdout.write(pformat(options))

        if options['daemonize'] and options['server_user'] and options['server_group']:
            # ensure the that the daemon runs as specified user
            change_uid_gid(options['server_user'], options['server_group'])

        from django_wsgiserver.wsgiserver import CherryPyWSGIServer, WSGIPathInfoDispatcher
        #from cherrypy.wsgiserver import CherryPyWSGIServer, WSGIPathInfoDispatcher

        from django.core.handlers.wsgi import WSGIHandler
        from django.conf import settings
        app = WSGIHandler()  # serve the django content
        path = {'/': app}  # well will build up the serving url routing path below

        # Now work on serving the static content
        # note as of django 1.4, ADMIN_MEDIA_PREFIX is depreciated and instead uses django.contrib.staticfiles
        # so it is not an error for ADMIN_MEDIA_PREFIX to not be defined, I will test to see if exists
        # and print a warning that adminserve is activated but it's not defined.
        # so for django 1.4 (or 1.5 ?) staticserve=True => adminserve=True
        # so the choices
        # There are basically two ways for statics to be served
        # 1. in development, one often wants each application's static files to be served from within its file structure
        #    this is what the django runserver dose
        # 2. in production usually, all the static files are collected into a common storage region (files, S3, CDN) and a good webserver
        #    serve them from there

        # deprecated
        # if options['adminserve']: # serve the admin media too
        # AdminMediaHandler is middleware for local use
        # import django.core.servers.basehttp
        # adminapp = django.core.servers.basehttp.AdminMediaHandler(app)
        # another way to serve the admin media three application
        #     if settings.__dict__.has_key('ADMIN_MEDIA_PREFIX'):
        #         import django.contrib.admin

        #         path[settings.ADMIN_MEDIA_PREFIX] = django_wsgiserver.mediahandler.StaticFileWSGIApplication(
        #             os.path.join( django.contrib.admin.__path__[0], 'media'))
        #     else:
        #         print "Warning adminserve was selected BUT ADMIN_MEDIA_PREFIX was not defined"

        if options['staticserve']:
            try:
                if not settings.STATIC_URL or not settings.STATIC_ROOT:
                    # could use misconfigured exception (what is this in django)  instead of AttributeError
                    fmtargs = (settings.STATIC_URL, settings.STATIC_ROOT)
                    errmsg = ((
                        "settings.STATIC_URL = {!r},"
                        "settings.STATIC_ROOT={!r}").format(*fmtargs))

                    raise AttributeError(errmsg)
            except AttributeError as msg:
                logger.error(msg)
                logger.error("****")
                logger.error("STATIC_URL and STATIC_ROOT  must be set in settings file for staticserve option to work in django_wsgiserver")
                logger.error("****")
                raise

            if options['staticserve'] != 'collectstatic':
                if settings.STATICFILES_FINDERS:  # find the apps' static files and add them to the path
                    logger.debug("see settings.STATICFILES_FINDERS")
#.........这里部分代码省略.........
开发者ID:Hernrup,项目名称:django-wsgiserver3,代码行数:103,代码来源:runwsgiserver.py

示例8: is_server_started

# 需要导入模块: from cherrypy.wsgiserver import CherryPyWSGIServer [as 别名]
# 或者: from cherrypy.wsgiserver.CherryPyWSGIServer import ssl_adapter [as 别名]
    sock.settimeout(1)
    try:
        sock.connect(('127.0.0.1', PORT))
        return True
    except Exception, err:
        return False
    finally:
        sock.close()


if __name__ == '__main__':
    if is_server_started():
        print('Git server is already started')
        sys.exit(0)

    certfile = keyfile = None
    if len(sys.argv) > 1:
        certfile = sys.argv[1]
    if len(sys.argv) > 2:
        keyfile = sys.argv[2]

    app = assemble_WSGI_git_app(content_path=GIT_DIR, uri_marker=URI_MARKER)
    httpd = CherryPyWSGIServer(('0.0.0.0', PORT), app)

    if certfile:
        httpd.ssl_adapter = SSLAdapter(certfile, keyfile)

    signal.signal(signal.SIGINT, stop)
    httpd.start()

开发者ID:fabregas,项目名称:fabnet,代码行数:31,代码来源:git_server.py


注:本文中的cherrypy.wsgiserver.CherryPyWSGIServer.ssl_adapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。