本文整理匯總了Python中ssl.OPENSSL_VERSION_INFO屬性的典型用法代碼示例。如果您正苦於以下問題:Python ssl.OPENSSL_VERSION_INFO屬性的具體用法?Python ssl.OPENSSL_VERSION_INFO怎麽用?Python ssl.OPENSSL_VERSION_INFO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類ssl
的用法示例。
在下文中一共展示了ssl.OPENSSL_VERSION_INFO屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_openssl_supports_tls_version_1_2
# 需要導入模塊: import ssl [as 別名]
# 或者: from ssl import OPENSSL_VERSION_INFO [as 別名]
def check_openssl_supports_tls_version_1_2(**kwargs):
import ssl
try:
openssl_version_tuple = ssl.OPENSSL_VERSION_INFO
if openssl_version_tuple[0] < 1 or openssl_version_tuple[2] < 1:
warnings.warn(
'Currently installed openssl version: %s does not '
'support TLS 1.2, which is required for use of iot-data. '
'Please use python installed with openssl version 1.0.1 or '
'higher.' % (ssl.OPENSSL_VERSION),
UnsupportedTLSVersionWarning
)
# We cannot check the openssl version on python2.6, so we should just
# pass on this conveniency check.
except AttributeError:
pass
示例2: check_openssl_supports_tls_version_1_2
# 需要導入模塊: import ssl [as 別名]
# 或者: from ssl import OPENSSL_VERSION_INFO [as 別名]
def check_openssl_supports_tls_version_1_2(**kwargs):
import ssl
try:
openssl_version_tuple = ssl.OPENSSL_VERSION_INFO
if openssl_version_tuple < (1, 0, 1):
warnings.warn(
'Currently installed openssl version: %s does not '
'support TLS 1.2, which is required for use of iot-data. '
'Please use python installed with openssl version 1.0.1 or '
'higher.' % (ssl.OPENSSL_VERSION),
UnsupportedTLSVersionWarning
)
# We cannot check the openssl version on python2.6, so we should just
# pass on this conveniency check.
except AttributeError:
pass
示例3: __connect
# 需要導入模塊: import ssl [as 別名]
# 或者: from ssl import OPENSSL_VERSION_INFO [as 別名]
def __connect(self):
err = self.__socket.connect_ex((self.__host, self.__port))
if not err:
self.__connect_ok = True
if self.__ssl_on:
self.__tls_ctx = ssl._create_unverified_context()
ssl_verinfo = ssl.OPENSSL_VERSION_INFO
# 隻有openssl 1.0.2版本及其以上才支持ALPN
if ssl_verinfo[0] >= 1 and ssl_verinfo[1] >= 0 and ssl_verinfo[2] >= 2:
self.__alpn_on = True
if self.__alpn_on:
alpn_protocols = ["http/1.1"]
self.__tls_ctx.set_alpn_protocols(alpn_protocols)
self.__socket = self.__tls_ctx.wrap_socket(self.__socket)
self.__socket.setblocking(0)
return
示例4: _certifi_where_for_ssl_version
# 需要導入模塊: import ssl [as 別名]
# 或者: from ssl import OPENSSL_VERSION_INFO [as 別名]
def _certifi_where_for_ssl_version():
"""Gets the right location for certifi certifications for the current SSL
version.
Older versions of SSL don't support the stronger set of root certificates.
"""
if not ssl:
return
if ssl.OPENSSL_VERSION_INFO < (1, 0, 2):
warnings.warn(
'You are using an outdated version of OpenSSL that '
'can\'t use stronger root certificates.')
return certifi.old_where()
return certifi.where()