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


Python SSL.SSLv3_METHOD方法代碼示例

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


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

示例1: convert_version2method

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import SSLv3_METHOD [as 別名]
def convert_version2method(protocol_version):
    """
    Convert internal protocol version ID to OpenSSL method.

    :param Integer protocol_version: Version ID
    :return: OpenSSL method or None if not found
    :rtype: OpenSSL method or None
    """
    if protocol_version == flextls.registry.version.SSLv2:
        return SSL.SSLv2_METHOD
    if protocol_version == flextls.registry.version.SSLv3:
        return SSL.SSLv3_METHOD
    if protocol_version == flextls.registry.version.TLSv10:
        return SSL.TLSv1_METHOD
    if protocol_version == flextls.registry.version.TLSv11:
        return SSL.TLSv1_1_METHOD
    if protocol_version == flextls.registry.version.TLSv12:
        return SSL.TLSv1_2_METHOD

    return None 
開發者ID:DinoTools,項目名稱:pysslscan,代碼行數:22,代碼來源:openssl.py

示例2: test_certificateOptionsSerialization

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import SSLv3_METHOD [as 別名]
def test_certificateOptionsSerialization(self):
        """
        Test that __setstate__(__getstate__()) round-trips properly.
        """
        firstOpts = sslverify.OpenSSLCertificateOptions(
            privateKey=self.sKey,
            certificate=self.sCert,
            method=SSL.SSLv3_METHOD,
            verify=True,
            caCerts=[self.sCert],
            verifyDepth=2,
            requireCertificate=False,
            verifyOnce=False,
            enableSingleUseKeys=False,
            enableSessions=False,
            fixBrokenPeers=True,
            enableSessionTickets=True)
        context = firstOpts.getContext()
        state = firstOpts.__getstate__()

        # The context shouldn't be in the state to serialize
        self.failIf(objgrep(state, context, isSame),
                    objgrep(state, context, isSame))

        opts = sslverify.OpenSSLCertificateOptions()
        opts.__setstate__(state)
        self.assertEqual(opts.privateKey, self.sKey)
        self.assertEqual(opts.certificate, self.sCert)
        self.assertEqual(opts.method, SSL.SSLv3_METHOD)
        self.assertEqual(opts.verify, True)
        self.assertEqual(opts.caCerts, [self.sCert])
        self.assertEqual(opts.verifyDepth, 2)
        self.assertEqual(opts.requireCertificate, False)
        self.assertEqual(opts.verifyOnce, False)
        self.assertEqual(opts.enableSingleUseKeys, False)
        self.assertEqual(opts.enableSessions, False)
        self.assertEqual(opts.fixBrokenPeers, True)
        self.assertEqual(opts.enableSessionTickets, True) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:40,代碼來源:test_sslverify.py


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