當前位置: 首頁>>代碼示例>>Python>>正文


Python SSL.ConnectionType方法代碼示例

本文整理匯總了Python中OpenSSL.SSL.ConnectionType方法的典型用法代碼示例。如果您正苦於以下問題:Python SSL.ConnectionType方法的具體用法?Python SSL.ConnectionType怎麽用?Python SSL.ConnectionType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenSSL.SSL的用法示例。


在下文中一共展示了SSL.ConnectionType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_getHandle

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import ConnectionType [as 別名]
def test_getHandle(self):
        """
        L{TLSMemoryBIOProtocol.getHandle} returns the L{OpenSSL.SSL.Connection}
        instance it uses to actually implement TLS.

        This may seem odd.  In fact, it is.  The L{OpenSSL.SSL.Connection} is
        not actually the "system handle" here, nor even an object the reactor
        knows about directly.  However, L{twisted.internet.ssl.Certificate}'s
        C{peerFromTransport} and C{hostFromTransport} methods depend on being
        able to get an L{OpenSSL.SSL.Connection} object in order to work
        properly.  Implementing L{ISystemHandle.getHandle} like this is the
        easiest way for those APIs to be made to work.  If they are changed,
        then it may make sense to get rid of this implementation of
        L{ISystemHandle} and return the underlying socket instead.
        """
        factory = ClientFactory()
        contextFactory = ClientContextFactory()
        wrapperFactory = TLSMemoryBIOFactory(contextFactory, True, factory)
        proto = TLSMemoryBIOProtocol(wrapperFactory, Protocol())
        transport = StringTransport()
        proto.makeConnection(transport)
        self.assertIsInstance(proto.getHandle(), ConnectionType) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:24,代碼來源:test_tls.py

示例2: makefile

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import ConnectionType [as 別名]
def makefile(self, sock, mode='r', bufsize=-1):
        if SSL and isinstance(sock, SSL.ConnectionType):
            timeout = sock.gettimeout()
            f = SSL_fileobject(sock, mode, bufsize)
            f.ssl_timeout = timeout
            return f
        else:
            return wsgiserver.CP_fileobject(sock, mode, bufsize) 
開發者ID:exiahuang,項目名稱:SalesforceXyTools,代碼行數:10,代碼來源:ssl_pyopenssl.py


注:本文中的OpenSSL.SSL.ConnectionType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。