我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用ssl.OPENSSL_VERSION_INFO。
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
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
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
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()
def ssl_version_check(): from ssl import OPENSSL_VERSION_INFO as sslv, OPENSSL_VERSION if not (sslv[0] > 1 or (sslv[0] == 1 and sslv[1] > 0) or (sslv[0] == 1 and sslv[1] == 0 and sslv[2] > 0)): raise Exception('At least SSL v1.0.1 required for TLS v1.2 (found %s)' % OPENSSL_VERSION) # callback function check helper