Supress InsecureRequestWarning for requests without ssl verify

This commit is contained in:
JonnyWong16
2020-05-16 17:30:44 -07:00
parent 9a00350ffc
commit 53aa740305

View File

@@ -23,6 +23,7 @@ from xml.dom import minidom
import collections
import requests
from requests.packages import urllib3
import plexpy
if plexpy.PYTHON2:
@@ -59,6 +60,8 @@ def request_response(url, method="get", auto_raise=True,
# Disable verification of SSL certificates if requested. Note: this could
# pose a security issue!
kwargs["verify"] = bool(plexpy.CONFIG.VERIFY_SSL_CERT)
if not kwargs['verify']:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Map method to the request.XXX method. This is a simple hack, but it
# allows requests to apply more magic per method. See lib/requests/api.py.
@@ -149,6 +152,8 @@ def request_response2(url, method="get", auto_raise=True,
# Disable verification of SSL certificates if requested. Note: this could
# pose a security issue!
kwargs['verify'] = bool(plexpy.CONFIG.VERIFY_SSL_CERT)
if not kwargs['verify']:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Map method to the request.XXX method. This is a simple hack, but it
# allows requests to apply more magic per method. See lib/requests/api.py.