本文整理匯總了Python中_ssl.PROTOCOL_SSLv3方法的典型用法代碼示例。如果您正苦於以下問題:Python _ssl.PROTOCOL_SSLv3方法的具體用法?Python _ssl.PROTOCOL_SSLv3怎麽用?Python _ssl.PROTOCOL_SSLv3使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類_ssl
的用法示例。
在下文中一共展示了_ssl.PROTOCOL_SSLv3方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_server_certificate
# 需要導入模塊: import _ssl [as 別名]
# 或者: from _ssl import PROTOCOL_SSLv3 [as 別名]
def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
"""Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
If 'ssl_version' is specified, use it in the connection attempt."""
host, port = addr
if (ca_certs is not None):
cert_reqs = CERT_REQUIRED
else:
cert_reqs = CERT_NONE
s = wrap_socket(socket(), ssl_version=ssl_version,
cert_reqs=cert_reqs, ca_certs=ca_certs)
s.connect(addr)
dercert = s.getpeercert(True)
s.close()
return DER_cert_to_PEM_cert(dercert)
示例2: test_constants
# 需要導入模塊: import _ssl [as 別名]
# 或者: from _ssl import PROTOCOL_SSLv3 [as 別名]
def test_constants(self):
self.assertEqual(real_ssl.CERT_NONE, 0)
self.assertEqual(real_ssl.CERT_OPTIONAL, 1)
self.assertEqual(real_ssl.CERT_REQUIRED, 2)
self.assertEqual(real_ssl.PROTOCOL_SSLv2, 0)
self.assertEqual(real_ssl.PROTOCOL_SSLv23, 2)
self.assertEqual(real_ssl.PROTOCOL_SSLv3, 1)
self.assertEqual(real_ssl.PROTOCOL_TLSv1, 3)
self.assertEqual(real_ssl.PROTOCOL_TLSv1_1, 4)
self.assertEqual(real_ssl.PROTOCOL_TLSv1_2, 5)
self.assertEqual(real_ssl.OP_NO_SSLv2, 0x1000000)
self.assertEqual(real_ssl.OP_NO_SSLv3, 0x2000000)
self.assertEqual(real_ssl.OP_NO_TLSv1, 0x4000000)
self.assertEqual(real_ssl.OP_NO_TLSv1_1, 0x10000000)
self.assertEqual(real_ssl.OP_NO_TLSv1_2, 0x8000000)
self.assertEqual(real_ssl.SSL_ERROR_EOF, 8)
self.assertEqual(real_ssl.SSL_ERROR_INVALID_ERROR_CODE, 9)
self.assertEqual(real_ssl.SSL_ERROR_SSL, 1)
self.assertEqual(real_ssl.SSL_ERROR_SYSCALL, 5)
self.assertEqual(real_ssl.SSL_ERROR_WANT_CONNECT, 7)
self.assertEqual(real_ssl.SSL_ERROR_WANT_READ, 2)
self.assertEqual(real_ssl.SSL_ERROR_WANT_WRITE, 3)
self.assertEqual(real_ssl.SSL_ERROR_WANT_X509_LOOKUP, 4)
self.assertEqual(real_ssl.SSL_ERROR_ZERO_RETURN, 6)
示例3: test_constants
# 需要導入模塊: import _ssl [as 別名]
# 或者: from _ssl import PROTOCOL_SSLv3 [as 別名]
def test_constants(self):
self.assertEqual(_ssl.CERT_NONE, 0)
self.assertEqual(_ssl.CERT_OPTIONAL, 1)
self.assertEqual(_ssl.CERT_REQUIRED, 2)
self.assertEqual(_ssl.PROTOCOL_SSLv2, 0)
self.assertEqual(_ssl.PROTOCOL_SSLv23, 2)
self.assertEqual(_ssl.PROTOCOL_SSLv3, 1)
self.assertEqual(_ssl.PROTOCOL_TLSv1, 3)
self.assertEqual(_ssl.PROTOCOL_TLSv1_1, 4)
self.assertEqual(_ssl.PROTOCOL_TLSv1_2, 5)
self.assertEqual(_ssl.OP_NO_SSLv2, 0x1000000)
self.assertEqual(_ssl.OP_NO_SSLv3, 0x2000000)
self.assertEqual(_ssl.OP_NO_TLSv1, 0x4000000)
self.assertEqual(_ssl.OP_NO_TLSv1_1, 0x10000000)
self.assertEqual(_ssl.OP_NO_TLSv1_2, 0x8000000)
self.assertEqual(_ssl.SSL_ERROR_EOF, 8)
self.assertEqual(_ssl.SSL_ERROR_INVALID_ERROR_CODE, 10)
self.assertEqual(_ssl.SSL_ERROR_SSL, 1)
self.assertEqual(_ssl.SSL_ERROR_SYSCALL, 5)
self.assertEqual(_ssl.SSL_ERROR_WANT_CONNECT, 7)
self.assertEqual(_ssl.SSL_ERROR_WANT_READ, 2)
self.assertEqual(_ssl.SSL_ERROR_WANT_WRITE, 3)
self.assertEqual(_ssl.SSL_ERROR_WANT_X509_LOOKUP, 4)
self.assertEqual(_ssl.SSL_ERROR_ZERO_RETURN, 6)