当前位置: 首页>>代码示例>>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;未经允许,请勿转载。