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


Python eventlet.wrap_ssl方法代码示例

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


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

示例1: requesting

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import wrap_ssl [as 别名]
def requesting(host, port, ca_certs=None, method="POST",
               content_type="application/x-www-form-urlencoded",
               address_familly=socket.AF_INET):
    frame = bytes("{verb} / HTTP/1.1\r\n\r\n".format(verb=method), "utf-8")
    with socket.socket(address_familly, socket.SOCK_STREAM) as sock:
        if ca_certs:
            with eventlet.wrap_ssl(sock, ca_certs=ca_certs) as wrappedSocket:
                wrappedSocket.connect((host, port))
                wrappedSocket.send(frame)
                data = wrappedSocket.recv(1024).decode()
                return data
        else:
            sock.connect((host, port))
            sock.send(frame)
            data = sock.recv(1024).decode()
            return data 
开发者ID:openstack,项目名称:oslo.service,代码行数:18,代码来源:test_wsgi.py

示例2: handle

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import wrap_ssl [as 别名]
def handle(self, listener, client, addr):
        if self.cfg.is_ssl:
            client = eventlet.wrap_ssl(client, server_side=True,
                                       **self.cfg.ssl_options)

        super(EventletWorker, self).handle(listener, client, addr) 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:geventlet.py

示例3: _command

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import wrap_ssl [as 别名]
def _command(self, command):
        sock = eventlet.wrap_ssl(
            eventlet.connect((self.host, self.port)),
            keyfile=self.keyfile,
            certfile=self.certfile)
        stream = sock.makefile()
        stream.write('%s %s\n' % (self.NSDCT_VERSION, command))
        stream.flush()
        result = stream.read()
        stream.close()
        sock.close()
        return result 
开发者ID:openstack,项目名称:designate,代码行数:14,代码来源:impl_nsd4.py

示例4: _run_server

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import wrap_ssl [as 别名]
def _run_server():
    host = cfg.CONF.auth.host
    port = cfg.CONF.auth.port
    use_ssl = cfg.CONF.auth.use_ssl

    cert_file_path = os.path.realpath(cfg.CONF.auth.cert)
    key_file_path = os.path.realpath(cfg.CONF.auth.key)

    if use_ssl and not os.path.isfile(cert_file_path):
        raise ValueError('Certificate file "%s" doesn\'t exist' % (cert_file_path))

    if use_ssl and not os.path.isfile(key_file_path):
        raise ValueError('Private key file "%s" doesn\'t exist' % (key_file_path))

    socket = eventlet.listen((host, port))

    if use_ssl:
        socket = eventlet.wrap_ssl(socket,
                                   certfile=cert_file_path,
                                   keyfile=key_file_path,
                                   server_side=True)

    LOG.info('ST2 Auth API running in "%s" auth mode', cfg.CONF.auth.mode)
    LOG.info('(PID=%s) ST2 Auth API is serving on %s://%s:%s.', os.getpid(),
             'https' if use_ssl else 'http', host, port)

    wsgi.server(socket, app.setup_app(), log=LOG, log_output=False)
    return 0 
开发者ID:StackStorm,项目名称:st2,代码行数:30,代码来源:api.py


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