- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对我学校网站的请求有疑问。我在网上搜索了解决方案,但没有一个对我有用。我已经通过 pip 安装了 certifi,它不起作用。我已经重新安装了 openssl,但它不起作用。
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2l 25 May 2017'
具体来说,SSL 验证是这里的问题。我可以用我的浏览器正确打开网页,没有任何 SSL 警告,但我不能用 Python。
那么,接下来我该做什么呢?希望有人能给我一点建议。非常感谢
最佳答案
通过阅读Python的requests
docs ,
我发现了以下内容,其中指出:
When you are using the prepared request flow, keep in mind that it does not take into account the environment. This can cause problems if you are using environment variables to change the behaviour of requests. For example: Self-signed SSL certificates specified in
REQUESTS_CA_BUNDLE
will not be taken into account. As a result anSSL: CERTIFICATE_VERIFY_FAILED
is thrown. You can get around this behaviour by explicity merging the environment settings into your session:from requests import Request, Session
s = Session()
req = Request('GET', url)
prepped = s.prepare_request(req)
# Merge environment settings into session
settings = s.merge_environment_settings(prepped.url, None, None, None, None)
resp = s.send(prepped, **settings)
print(resp.status_code)
我建议阅读文档,因为我只是引用了原始文档的一部分。
除此之外,
Requests verifies SSL certificates for HTTPS requests, just like a web browser. By default, SSL verification is enabled, and Requests will throw a SSLError if it's unable to verify the certificate.
您可以使用verify
参数来提供指向CA_BUNDLE
文件或目录的路径,其中包含可信CA 的证书:
>>> requests.get('https://your-school-website-url.com', verify='/path/to/cacert_file')
Requests
也可以忽略验证SSL 证书 如果您设置verify
为 False
:
>>> requests.get('https://kennethreitz.org', verify=False)
<Response [200]>
默认情况下,verify
设置为True
。选项验证仅适用于主机证书。
再次,请阅读 docs .
关于Python SSL 错误 CERTIFICATE_VERIFY_FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45989672/
你知道为什么会调用 badCertificateCallback 吗?证书( Dart 声称无效)与我设置为受信任证书的证书完全相同(相等性检查为真!)。 import 'dart:convert';
我最近将一个项目从 1.22.1 升级到 1.24.3。随后,pub get 失败了 Handshake error in client (OS Error: CERTIFICATE_VERIFY_F
我有一个使用 VirusTotal API 的 python 脚本。它一直没有问题,但是当我运行脚本时突然出现以下错误: urllib2.URLError: 我认为可能是我们的网络代理导致了这个问题
我使用以下代码通过 XMLRPC api 与 Magento 网上商店进行交互。 Magento API Python XMLRPC 一切正常,直到我们将 Web 服务器更改为 SSL 现在我收到以下
在使用 Windows 8.1 的相当新的机器上使用 Python 2.7.12 连接到 www.mydomain.com 时出现错误。错误是 SSL: CERTIFICATE_VERIFY_FAIL
我正在尝试创建一个虚拟环境,过去我可以通过诗歌安装来做到这一点。但是现在当尝试执行 poetry install 时,我收到了这条消息: Max retries exceeded with url:
我使用 python + boto3 在 bitbucket 管道中为 AWS IOT 运行测试脚本 直到最近它工作正常,现在我收到以下错误: Traceback (most recent call
这个问题在这里已经有了答案: youtube-dl gave me an error about ssl (2 个回答) 去年关闭。 我在 Python 中运行了这段代码: from __future
我正在尝试按照 Google 的文档构建我自己的 Android 版本,但它在“repo init”状态下失败(第 2 部分的第 2 步): https://source.android.com/so
好吧,我正在尝试为我的旅馆 wifi 创建一个自动登录脚本,我需要登录到 wifi 才能获得网络访问权限。如果我连接到 wifi,该网页在本地网络上保持打开状态。我只需要访问该网页并在那里登录即可。所
所以我目前正在制作一个 Xamarin.Android 应用程序,一段时间以来它一直使用我制作的 REST API 来与数据来回通信。 不过,我最近将我的 SSL 证书切换到了 LetsEncrypt
在证书有效的某些站点上,在 python 3.5 中使用 urllib3 发出 GET 请求失败并出现错误 CERTIFICATE_VERIFY_FAILED。 import certifi impo
我正在努力解决这个问题 requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
from lxml import html import requests url = "https://website.com/" page = requests.get(url) tree = h
我对我学校网站的请求有疑问。我在网上搜索了解决方案,但没有一个对我有用。我已经通过 pip 安装了 certifi,它不起作用。我已经重新安装了 openssl,但它不起作用。 >>> import
更新 (2019-02-07):issue现已修复,因此如果您仍然遇到此问题,请尝试 gcloud components update。 在过去几个月的某个时候,我的 bq 工具停止工作了。即使是一个
我正在使用 python 2.7.10 request = urllib2.Request(url, data=urllib.urlencode(params)) f = urllib2.urlope
如果这是一个愚蠢的问题,我深表歉意,但我一直在尝试自学如何使用 BeautifulSoup,以便我可以创建一些项目。 我正在关注此链接作为教程:https://www.youtube.com/watc
我本来想解决 [SSL: CERTIFICATE_VERIFY_FAILED] 问题,因为我使用 mac 和 python 3,很多人说我应该运行/Applications/Python\3.6/In
我收到以下错误: Exception in thread Thread-3: Traceback (most recent call last): File "/Library/Frameworks/
我是一名优秀的程序员,十分优秀!