3

even though i keep verify= false, i'm getting ssl error in python. Could you tell me how do I avoid it? But curl command is working with -k option.

import json
import requests

url = "https://<url>/context"
payload = {"some":"data"}
headers = {"Authorization": "Basic:xxxxxxxxxx"}

response = requests.post(url, verify=False, 
data=json.dumps(payload), headers=headers)

print(response)

error:

/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning)

3
  • 1
    That's no error, that's a warning. Also, the warning message even gave you directly the link discussing how to handle it.
    – eis
    Commented Apr 4, 2017 at 6:37
  • Furthermore, Authorization header doesn't work like that. You need a space after Basic.
    – eis
    Commented Apr 4, 2017 at 6:42
  • ah! my bad. thank you for pointing the error. :)
    – santosh.a
    Commented Apr 4, 2017 at 9:52

1 Answer 1

1

It is just a warning. You can disable these warnings.

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.