0

Here's the thing , I have been trying to send POST request to LOGIN to my college wifi page from within python but I am getting SSL certicate error . The POST request works fine from POSTMAN extention of chrome.

Here is how the request looks like when I use the chrome'e debugger to see the POST requests

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-downgrade

POST /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

I found that the Problem was in specifying 'http' in the post request url , which should have been https .

When I use https however , I get the python's SSL certificate error .

I have tried giving verify=False parameter with no luck . I have also tried giving path to certificate like this :-

    resp = S.post("https://112.133.253.2:8090/login.xml" ,
 data = data  ,
 verify = "/etc/ssl/certs/ca-certificates.crt") ;

But nothing works .

How is the extension of postman working without giving SSL certificate errors ? How can I fix this issue to send the requests from Python itself ?

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
  • This solved my problem [follo link to resolve problem](https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests) – GANESH CHOKHARE Jun 25 '18 at 12:23
  • It help me to solved my problem. refer this [link](https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests) – GANESH CHOKHARE Jun 25 '18 at 13:27

1 Answers1

1

Try disabling warnings like this:

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

Hope it helps.

  • this isn't a fix – iphaaw Nov 12 '18 at 14:49
  • Indeed this does not get rid of the underlying issue, which I would assume comes from using a self signed certificate (?), and there is no way of knowing if Postman isn't generating the same warning under the hood. The OP was prepared to disable verification, but as reported this still results in the same warnings being generated, while the above does not. For a more complete answer see this related [question](https://stackoverflow.com/questions/30405867/how-to-get-python-requests-to-trust-a-self-signed-ssl-certificate). – Robin Keskisarkka Nov 16 '18 at 10:28