當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。