相关疑难解决方法(0)

如何在Python请求中禁用安全证书检查

我在用

import requests
requests.post(url='https://foo.com', data={'bar':'baz'})
Run Code Online (Sandbox Code Playgroud)

但是我收到了request.exceptions.SSLError.该网站有一个过期的证书,但我没有发送敏感数据,所以对我来说无关紧要.我想我可以使用像'verifiy = False'这样的论点,但我似乎无法找到它.

python https python-requests

191
推荐指数
7
解决办法
29万
查看次数

Python请求获取SSLerror

尝试使用Requests会话发出一个简单的get请求,但我一直在为特定站点获取SSLerror.我想也许问题出在网站上(我使用https://www.ssllabs.com进行了扫描,结果如下),但我不能确定,因为我对此领域一无所知:)我肯定会喜欢了解发生了什么.

解决方案/解释会很棒,谢谢!

代码:

import requests

requests.get('https://www.reporo.com/')
Run Code Online (Sandbox Code Playgroud)

我收到了下一个错误:

SSLError: [Errno bad handshake] [('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')]

---------------------------------------------------------------------------
SSLError                                  Traceback (most recent call last)
<ipython-input-7-cfc21b287fee> in <module>()
----> 1 requests.get('https://www.reporo.com/')

/usr/local/lib/python2.7/dist-packages/requests/api.pyc in get(url, **kwargs)
     63 
     64     kwargs.setdefault('allow_redirects', True)
---> 65     return request('get', url, **kwargs)
     66 
     67 

/usr/local/lib/python2.7/dist-packages/requests/api.pyc in request(method, url, **kwargs)
     47 
     48     session = sessions.Session()
---> 49     response = session.request(method=method, url=url, **kwargs)
     50     # By explicitly closing the session, we avoid leaving sockets open which
     51     # …
Run Code Online (Sandbox Code Playgroud)

python ssl ssl-certificate python-requests

17
推荐指数
2
解决办法
3万
查看次数

使用 wincertstore 的 Python 请求

我正在尝试通过请求包连接到我公司的内部网页,但由于 python 不使用 Windows 默认可信证书,因此连接被拒绝。我发现 wincertstore 可用于获取 Windows 默认证书。但我仍然不确定如何将它与我的请求一起使用。以下是我迄今为止尝试过的代码......

import requests, socket, atexit, ssl, wincertstore
from requests.auth import HTTPBasicAuth
certfile = wincertstore.CertFile()
certfile.addstore("CA")
certfile.addstore("ROOT")
atexit.register(certfile.close)
ssl_sock = ssl.wrap_socket(s,ca_certs=certfile.name, 
cert_reqs=ssl.CERT_REQUIRED)
requests.get(url)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误...... requests.exceptions.SSLError: HTTPSConnectionPool(host='myhost', port=443): Max retries exceeded with url: myurl (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

我可以在同一个网址上使用 wget 并下载内容。

wget --no check certificate --user=my username --password=my password URL

但我对下载内容不感兴趣,因为我只需要抓取网页内容的一小部分。

Python 版本 = 3.6.5

Wincertstore 链接 -链接

在此先感谢您的帮助..............

python ssl-certificate python-requests

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×3

python-requests ×3

ssl-certificate ×2

https ×1

ssl ×1