事情是这样的,我一直试图发送从python内部登录到我的大学wifi页面的帖子请求,但是我得到了SSL证书错误。通过邮递员对铬的扩展,邮政请求可以正常工作。
下面是当我使用chrome调试器查看POST请求时请求的样子
Request URL:https://112.133.253.2:8090/login.xml
Request Method:POST
Status Code:200 OK
Remote Address:112.133.253.2:8090
Referrer Policy:no-referrer-when-downgradePOST /login.xml HTTP/1.1
Host: 112.133.253.2:8090
Connection: keep-alive
Content-Length: 72
Origin: https://112.133.253.2:8090
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: https://112.133.253.2:8090/httpclient.html
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9我发现问题是在post请求url中指定'http‘,应该是https。
然而,当我使用https时,我会得到python的SSL证书错误。
我尝试过给出verify=False参数,但没有结果。我亦曾尝试提供这样的证书途径:
resp = S.post("https://112.133.253.2:8090/login.xml" ,
data = data ,
verify = "/etc/ssl/certs/ca-certificates.crt") ;但什么都不管用。
邮递员的扩展是如何工作而不提供SSL证书错误的?如何解决此问题以发送来自Python本身的请求?
发布于 2017-12-14 11:31:16
尝试禁用以下警告:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)希望能帮上忙。
https://stackoverflow.com/questions/47130157
复制相似问题