本文整理汇总了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")
示例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
示例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")
示例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