绕过python中的ssl证书验证

时间:2017-04-04 06:27:09

标签: python https python-requests

即使我保持verify = false,我在python中得到ssl错误。你能告诉我怎么避免它吗?但是curl命令正在使用-k选项。

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)

错误:

/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769:InsecureRequestWarning:正在进行未经验证的HTTPS请求。强烈建议添加证书验证。请参阅:https://urllib3.readthedocs.org/en/latest/security.html   InsecureRequestWarning)

1 个答案:

答案 0 :(得分:1)

这只是一个警告。您可以禁用这些警告。

import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, aspect='equal')
ax2.add_patch(
    patches.RegularPolygon(
        (0.5, 0.5),
        3,
        0.2,
        fill=False      # remove background
    )
)

fig2.savefig('reg-polygon.png', dpi=90, bbox_inches='tight')
plt.show()