当前位置: 首页>>代码示例>>Python>>正文


Python ssl.OPENSSL_VERSION属性代码示例

本文整理汇总了Python中ssl.OPENSSL_VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python ssl.OPENSSL_VERSION属性的具体用法?Python ssl.OPENSSL_VERSION怎么用?Python ssl.OPENSSL_VERSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ssl的用法示例。


在下文中一共展示了ssl.OPENSSL_VERSION属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_regrtests

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def run_regrtests(*extra_args):
    print(ssl.OPENSSL_VERSION)
    args = [
        sys.executable,
        '-Werror', '-bb',  # turn warnings into exceptions
        '-m', 'test.regrtest',
    ]
    if not extra_args:
        args.extend([
            '-r',  # randomize
            '-w',  # re-run failed tests with -v
            '-u', 'network',  # use network
            '-u', 'urlfetch',  # download test vectors
        ])
    else:
        args.extend(extra_args)
    args.extend(TESTS)
    result = subprocess.call(args)
    sys.exit(result) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:ssltests.py

示例2: check_openssl_supports_tls_version_1_2

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [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 
开发者ID:skarlekar,项目名称:faces,代码行数:18,代码来源:handlers.py

示例3: check_openssl_supports_tls_version_1_2

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [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 
开发者ID:QData,项目名称:deepWordBug,代码行数:18,代码来源:handlers.py

示例4: get_version_info

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def get_version_info(scope):
    versioninfo = 'docker-compose version {}, build {}'.format(
        compose.__version__,
        get_build_version())

    if scope == 'compose':
        return versioninfo
    if scope == 'full':
        return (
            "{}\n"
            "docker-py version: {}\n"
            "{} version: {}\n"
            "OpenSSL version: {}"
        ).format(
            versioninfo,
            docker.version,
            platform.python_implementation(),
            platform.python_version(),
            ssl.OPENSSL_VERSION)

    raise ValueError("{} is not a valid version scope".format(scope)) 
开发者ID:QData,项目名称:deepWordBug,代码行数:23,代码来源:utils.py

示例5: run_regrtests

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def run_regrtests(*extra_args):
    print(ssl.OPENSSL_VERSION)
    args = [
        sys.executable,
        '-Werror', '-bb',  # turn warnings into exceptions
        '-m', 'test',
    ]
    if not extra_args:
        args.extend([
            '-r',  # randomize
            '-w',  # re-run failed tests with -v
            '-u', 'network',  # use network
            '-u', 'urlfetch',  # download test vectors
            '-j', '0'  # use multiple CPUs
        ])
    else:
        args.extend(extra_args)
    args.extend(TESTS)
    result = subprocess.call(args)
    sys.exit(result) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:22,代码来源:ssltests.py

示例6: _rome_warning

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def _rome_warning(self, reason):
        # "Connection reset by peer" or
        # "EOF occurred in violation of protocol"
        # may indicate no TLS 1.[12]
        if (('Errno 54' in reason or
                'EOF occurred in violation of protocol' in reason) and
                hasattr(ssl, 'OPENSSL_VERSION_NUMBER') and
                ssl.OPENSSL_VERSION_NUMBER < 0x1000100):
            x = 'WARNING: Your SSL (%s) may not support TLS 1.1.' % \
                ssl.OPENSSL_VERSION
            x += ' PAN-OS 8.0 does not allow TLS 1.0 connections by default.'
            self._log(DEBUG1, x) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:14,代码来源:xapi.py

示例7: systemInfo

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- # 
开发者ID:a4k-openproject,项目名称:a4kScrapers,代码行数:29,代码来源:help.py

示例8: request_exc_message

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def request_exc_message(exc, conn):
    """
    Return a reasonable exception message from a requests exception.

    The approach is to dig deep to the original reason, if the original
    exception is present, skipping irrelevant exceptions such as
    `urllib3.exceptions.MaxRetryError`, and eliminating useless object
    representations such as the connection pool object in
    `urllib3.exceptions.NewConnectionError`.

    Parameters:
      exc (requests.exceptions.RequestException): Exception
      conn (WBEMConnection): Connection that was used.

    Returns:
      string: A reasonable exception message from the specified exception.
    """
    if exc.args:
        if isinstance(exc.args[0], Exception):
            org_exc = exc.args[0]
            if isinstance(org_exc, urllib3.exceptions.MaxRetryError):
                reason_exc = org_exc.reason
                message = str(reason_exc)
            else:
                message = str(org_exc.args[0])
        else:
            message = str(exc.args[0])

        # Eliminate useless object repr at begin of the message
        m = re.match(r'^(\(<[^>]+>, \'(.*)\'\)|<[^>]+>: (.*))$', message)
        if m:
            message = m.group(2) or m.group(3)
    else:
        message = ""

    if conn.scheme == 'https':
        message = message + \
            "; OpenSSL version used: {}".format(ssl.OPENSSL_VERSION)

    return message 
开发者ID:pywbem,项目名称:pywbem,代码行数:42,代码来源:_cim_http.py

示例9: get_https_context_factory

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def get_https_context_factory():
    if not hasattr(ssl, 'Purpose'):
        return lambda *_, **__: None
    if not hasattr(ssl, '_create_default_https_context') or \
       hasattr(ssl, 'get_default_verify_paths') and \
       ssl.get_default_verify_paths()[0] is None:
        m = re.match(r'(Open|Libre)SSL (\d+)\.(\d+)\.(\d+)',
                     ssl.OPENSSL_VERSION)
        openssl_version = int(m.group(2)), int(m.group(3)), int(m.group(4))
        if openssl_version < (1, 0, 2) and hasattr(certifi, 'old_where'):
            # https://github.com/certifi/python-certifi/issues/26
            where = certifi.old_where
        else:
            where = certifi.where

        def get_https_context(purpose=ssl.Purpose.SERVER_AUTH,
                              cafile=None, capath=None, cadata=None):
            return ssl.create_default_context(
                purpose=purpose,
                cafile=cafile or where(),
                capath=capath,
                cadata=cadata
            )
        return get_https_context
    if hasattr(ssl, '_create_default_https_context'):
        return ssl._create_default_https_context
    if hasattr(ssl, 'create_default_context'):
        return ssl.create_default_context
    return lambda *_, **__: None 
开发者ID:spoqa,项目名称:geofront-cli,代码行数:31,代码来源:ssl.py

示例10: __init__

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def __init__(self,
                 api_version=None,
                 panrc_tag=None,
                 hostname=None,
                 api_key=None,
                 timeout=None,
                 verify_cert=True):
        self._log = logging.getLogger(__name__).log
        self.api_version = api_version
        self.panrc_tag = panrc_tag
        self.hostname = hostname
        self.api_key = api_key
        self.timeout = timeout
        self.verify_cert = verify_cert

        self._log(DEBUG3, 'Python version: %s', sys.version)
        self._log(DEBUG3, 'ssl: %s', ssl.OPENSSL_VERSION)
        self._log(DEBUG3, 'pan-python version: %s', __version__)

        init_panrc = {}  # .panrc args from constructor
        if hostname is not None:
            init_panrc['hostname'] = hostname
        if api_key is not None:
            init_panrc['api_key'] = api_key

        try:
            panrc = pan.rc.PanRc(tag=self.panrc_tag,
                                 init_panrc=init_panrc)
        except pan.rc.PanRcError as e:
            raise PanLicapiError(e)

        if 'api_key' in panrc.panrc:
            self.api_key = panrc.panrc['api_key']
        if 'hostname' in panrc.panrc:
            self.hostname = panrc.panrc['hostname']
        else:
            self.hostname = _cloud_server

        if self.api_key is None:
            raise PanLicapiError('api_key required')

        self.uri = 'https://' + self.hostname
        self.base_uri = self.uri + '/api/license'
        self.headers = {
            'apikey': self.api_key,
            # requests header value must be str:
            #   https://github.com/kennethreitz/requests/issues/3477
            'version': str(int(api_version)),
        }

        try:
            self.http = pan.http.PanHttp(timeout=self.timeout,
                                         verify_cert=self.verify_cert)
        except pan.http.PanHttpError as e:
            raise PanLicapiError(e)

        if self.http.using_requests:
            s = 'using requests %s' % self.http.requests_version
        else:
            s = 'using urllib'
        self._log(DEBUG2, s) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:63,代码来源:v1.py

示例11: __init__

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def __init__(self,
                 api_version=None,
                 panrc_tag=None,
                 hostname=None,
                 api_key=None,
                 timeout=None,
                 verify_cert=True,
                 sleeper=None):
        self._log = logging.getLogger(__name__).log
        self.api_version = api_version
        self.panrc_tag = panrc_tag
        self.hostname = hostname
        self.api_key = api_key
        self.timeout = timeout
        self.verify_cert = verify_cert
        self.sleeper = _Sleeper if sleeper is None else sleeper

        self._log(DEBUG3, 'Python version: %s', sys.version)
        self._log(DEBUG3, 'ssl: %s', ssl.OPENSSL_VERSION)
        self._log(DEBUG3, 'pan-python version: %s', __version__)

        init_panrc = {}  # .panrc args from constructor
        if hostname is not None:
            init_panrc['hostname'] = hostname
        if api_key is not None:
            init_panrc['api_key'] = api_key

        try:
            panrc = pan.rc.PanRc(tag=self.panrc_tag,
                                 init_panrc=init_panrc)
        except pan.rc.PanRcError as e:
            raise PanAFapiError(e)

        if 'api_key' in panrc.panrc:
            self.api_key = panrc.panrc['api_key']
        if 'hostname' in panrc.panrc:
            self.hostname = panrc.panrc['hostname']
        else:
            self.hostname = _cloud_server

        if self.api_key is None:
            raise PanAFapiError('api_key required')

        self.uri = 'https://' + self.hostname
        self.base_uri = self.uri + '/api/' + str(api_version)
        self.headers = {'content-type': 'application/json'}

        try:
            self.http = pan.http.PanHttp(timeout=self.timeout,
                                         verify_cert=self.verify_cert)
        except pan.http.PanHttpError as e:
            raise PanAFapiError(e)

        if self.http.using_requests:
            s = 'using requests %s' % self.http.requests_version
        else:
            s = 'using urllib'
        self._log(DEBUG2, s) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:60,代码来源:v1_0.py

示例12: get_environ

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import OPENSSL_VERSION [as 别名]
def get_environ(self, sock):
        """Create WSGI environ entries to be merged into each request."""
        cipher = sock.cipher()
        ssl_environ = {
            'wsgi.url_scheme': 'https',
            'HTTPS': 'on',
            'SSL_PROTOCOL': cipher[1],
            'SSL_CIPHER': cipher[0],
            'SSL_CIPHER_EXPORT': '',
            'SSL_CIPHER_USEKEYSIZE': cipher[2],
            'SSL_VERSION_INTERFACE': '%s Python/%s' % (
                HTTPServer.version, sys.version,
            ),
            'SSL_VERSION_LIBRARY': ssl.OPENSSL_VERSION,
            'SSL_CLIENT_VERIFY': 'NONE',
            # 'NONE' - client did not provide a cert (overriden below)
        }

        # Python 3.3+
        with suppress(AttributeError):
            compression = sock.compression()
            if compression is not None:
                ssl_environ['SSL_COMPRESS_METHOD'] = compression

        # Python 3.6+
        with suppress(AttributeError):
            ssl_environ['SSL_SESSION_ID'] = sock.session.id.hex()
        with suppress(AttributeError):
            target_cipher = cipher[:2]
            for cip in sock.context.get_ciphers():
                if target_cipher == (cip['name'], cip['protocol']):
                    ssl_environ['SSL_CIPHER_ALGKEYSIZE'] = cip['alg_bits']
                    break

        # Python 3.7+ sni_callback
        with suppress(AttributeError):
            ssl_environ['SSL_TLS_SNI'] = sock.sni

        if self.context and self.context.verify_mode != ssl.CERT_NONE:
            client_cert = sock.getpeercert()
            if client_cert:
                # builtin ssl **ALWAYS** validates client certificates
                # and terminates the connection on failure
                ssl_environ['SSL_CLIENT_VERIFY'] = 'SUCCESS'
                ssl_environ.update(
                    self._make_env_cert_dict('SSL_CLIENT', client_cert),
                )
                ssl_environ['SSL_CLIENT_CERT'] = ssl.DER_cert_to_PEM_cert(
                    sock.getpeercert(binary_form=True),
                ).strip()

        ssl_environ.update(self._server_env)

        # not supplied by the Python standard library (as of 3.8)
        # - SSL_SESSION_RESUMED
        # - SSL_SECURE_RENEG
        # - SSL_CLIENT_CERT_CHAIN_n
        # - SRP_USER
        # - SRP_USERINFO

        return ssl_environ 
开发者ID:cherrypy,项目名称:cheroot,代码行数:63,代码来源:builtin.py


注:本文中的ssl.OPENSSL_VERSION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。