tornado2.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:http2 作者: mSOHU 项目源码 文件源码
def ssl_wrap_socket(cls, s, ssl_options, server_hostname=None, **kwargs):
        """Returns an ``ssl.SSLSocket`` wrapping the given socket.

        ``ssl_options`` may be either a dictionary (as accepted by
        `ssl_options_to_context`) or an `ssl.SSLContext` object.
        Additional keyword arguments are passed to ``wrap_socket``
        (either the `~ssl.SSLContext` method or the `ssl` module function
        as appropriate).
        """
        context = ssl_options_to_context(ssl_options)
        if hasattr(ssl, 'SSLContext') and isinstance(context, ssl.SSLContext):
            if server_hostname is not None and getattr(ssl, 'HAS_SNI'):
                # Python doesn't have server-side SNI support so we can't
                # really unittest this, but it can be manually tested with
                # python3.2 -m tornado.httpclient https://sni.velox.ch
                return context.wrap_socket(s, server_hostname=server_hostname,
                                           **kwargs)
            else:
                return context.wrap_socket(s, **kwargs)
        else:
            return ssl.wrap_socket(s, **dict(context, **kwargs))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号