I often use the Python requests library because it's so convenient. It's annoying to get some warning at the time of execution.
For example, Insecure Platform Warning appears. I tried to deal with it by referring to this person, but it is troublesome to put in a package or downgrade.
So I decided to forcibly rewrite the source code.
Easy to rewrite.
In my case, I got this warning,
/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Since the path of the source code is written carefully, open it with vim or something,
vim /usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py
It is OK if you comment out warnings.warn as follows
def wrap_socket(self, socket, server_hostname=None, server_side=False):
#warnings.warn(
# 'A true SSLContext object is not available. This prevents '
# 'urllib3 from configuring SSL appropriately and may cause '
# 'certain SSL connections to fail. You can upgrade to a newer '
# 'version of Python to solve this. For more information, see '
# 'https://urllib3.readthedocs.io/en/latest/security.html'
# '#insecureplatformwarning.',
# InsecurePlatformWarning
#)
kwargs = {
'keyfile': self.keyfile,
'certfile': self.certfile,
'ca_certs': self.ca_certs,
'cert_reqs': self.verify_mode,
'ssl_version': self.protocol,
'server_side': server_side,
}
This is enough! ?? w
Recommended Posts