tornado2.py 文件源码

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

项目:http2 作者: mSOHU 项目源码 文件源码
def _verify_cert(self, peer_cert):
        """Returns True if peercert is valid according to the configured
        validation mode and hostname.

        The ssl handshake already tested the certificate for a valid
        CA signature; the only thing that remains is to check
        the hostname.
        """
        verify_mode = self.ssl_options.verify_mode
        assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL)
        if verify_mode == ssl.CERT_NONE or self.host is None:
            return True

        if peer_cert is None and verify_mode == ssl.CERT_REQUIRED:
            logger.warning("No SSL certificate given")
            return False
        try:
            ssl_match_hostname(peer_cert, self.host)
        except SSLCertificateError:
            logger.warning("Invalid SSL certificate", exc_info=True)
            return False
        else:
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号