证书检查因Python请求而失败

时间:2020-04-22 21:06:10

标签: python ssl python-requests ssl-certificate

我正在尝试通过http / https代理使用Python requests package加载网站:

url = 'https://booster-magazine.ch'  # Example of failing URL
proxies = {
    'http': 'proxy.domain.internal:4321',
    'https': 'proxy.domain.internal:4321',
}
r = requests.get(url, proxies=proxies)

运行此命令将触发以下错误消息 requests.exceptions.SSLError: ("bad handshake: Error([('SSL Routine', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

Web浏览器表明该站点的证书是受信任的,并且使用与python代码相同的webproxy在命令行上使用cURL即可。

curl -x proxy.domain.internal:4321 https://booster-magazine.ch  # No error

我测试过的某些网站失败了,而其他网站运行良好。据我所知,这个失败站点的SSL Labs report没有任何问题。

我正在使用的软件包版本:

requests==2.23.0
certifi==2020.4.5.1

我知道请求库中存在verify=False选项。这通常是一种不好的做法,并可能导致mitm攻击。目的是要进行有效的ssl验证。

0 个答案:

没有答案