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


Python SSL.TLSv1_2_METHOD方法代碼示例

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


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

示例1: assertTlsHandshakeFailure

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import TLSv1_2_METHOD [as 別名]
def assertTlsHandshakeFailure(self, base_url, client_cert, client_key, ciphers=None, ssl_method=None):
    """
    Checks that the TLS handshake failure by varying the given parameters
    Args:
      base_url: Target host (defaults to port 443) or host:port.
      client_cert: client certificate file in PEM format to use.
      client_key: associated key file in PEM format to use with the
        given |client_cert|.
      ciphers: optional cipher method. TODO: Rename to 'cipher'.
      ssl_method: optional ssl_method
    """
    if ciphers is None:
      ciphers = [self._sas._tls_config.ciphers[0]]
      self.assertEqual(ciphers, ['AES128-GCM-SHA256'])
    else:
      ciphers = [ciphers]

    if ssl_method is None:
      ssl_method = SSL.TLSv1_2_METHOD

    self.assertFalse(
        self.doTlsHandshake(base_url, client_cert, client_key,
                            ciphers, ssl_method),
        "Handshake succeeded unexpectedly") 
開發者ID:Wireless-Innovation-Forum,項目名稱:Spectrum-Access-System,代碼行數:26,代碼來源:security_testcase.py

示例2: convert_version2method

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import TLSv1_2_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

示例3: assertTlsHandshakeSucceed

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import TLSv1_2_METHOD [as 別名]
def assertTlsHandshakeSucceed(self, base_url, ciphers, client_cert, client_key):
    """Checks that the TLS handshake succeed with the given parameters.

    Attempts to establish a TLS session with the given |base_url|, using the
    given |ciphers| list and the given certificate key pair.
    Checks that he SAS UUT response must satisfy all of the following conditions:
    - The SAS UUT agrees to use a cipher specified in the |ciphers| list
    - The SAS UUT agrees to use TLS Protocol Version 1.2
    - Valid Finished message is returned by the SAS UUT immediately following
      the ChangeCipherSpec message
    """
    self.assertTrue(
        self.doTlsHandshake(base_url, client_cert, client_key, ciphers,
                            SSL.TLSv1_2_METHOD),
        "Handshake failed unexpectedly") 
開發者ID:Wireless-Innovation-Forum,項目名稱:Spectrum-Access-System,代碼行數:17,代碼來源:security_testcase.py

示例4: _ssl_options

# 需要導入模塊: from OpenSSL import SSL [as 別名]
# 或者: from OpenSSL.SSL import TLSv1_2_METHOD [as 別名]
def _ssl_options(sslkey, sslcert):
    with open(sslkey) as keyfile:
        pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, keyfile.read())
    with open(sslcert) as certfile:
        cert = crypto.load_certificate(crypto.FILETYPE_PEM, certfile.read())

    acceptable = ssl.AcceptableCiphers.fromOpenSSLCipherString(
        u'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:!RC4:HIGH:!MD5:!aNULL:!EDH')
    options = ssl.CertificateOptions(privateKey=pkey,
                                     certificate=cert,
                                     method=SSL.TLSv1_2_METHOD,
                                     acceptableCiphers=acceptable)
    return options 
開發者ID:pixelated,項目名稱:pixelated-user-agent,代碼行數:15,代碼來源:application.py


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