English 中文(简体)
问讯室 证明
原标题:Issue with Python Requests Library: Getting SSL Certificate Verify Failed Error

目前,Im公司正在研制一种利用请求书库制作APIC申请的灰色文字。 然而,我面临一个问题,即我一直收到“SL证书,核实失败”错误。 我尝试在网上寻找解决办法,但建议的解决办法似乎没有发挥作用。

下面是我守则的简化版本:

import requests

url =  https://example.com/api 
response = requests.get(url)

print(response.text)

这里传递错误信息,我碰到:

请求:SLError: HTTPSConnectionPool(host= example.com, Port=443):Max retries over with url:

我已尝试更新证书图书馆,将核查参数定为法尔(我知道这不是建议的解决办法),并检查系统的时间。 尽管做出了这些努力,但问题依然存在。

Can someone please help me understand what might be causing this SSL certificate verification error and suggest a reliable solution? Any insights or guidance would be greatly appreciated!

问题回答

requests module s verify=True uses its own CA set that might not have CA that signed your server certificate.

您需要找到您的系统所在地。

And then add that as your verify argument parameter.

import requests

url =  https://example.com/api 
response = requests.get(url, verify="pathToCAFile")

print(response.text)

或者,如果你只是想在不确定根本问题的情况下确定警告,那么你就可以利用“urllib”模块来消除这一威胁:

import requests
import urllib3
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)

res = requests.get( https://example.com ,verify=False)




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签