头图

Anaconda or python3 reports check_hostname requires server_hostname error

墨抒颖
中文

Go to Mo Shuying's website to view the pure version

Anaconda or python3 reports check_hostname requires server_hostname error

The following error is prompted during the startup of anaconda

anaconda-check_hostname-requires-server_hostname-error.png

Or you can see a similar error python3

python-error.jpg

Error resolution

The main reason for the problem is a bug in the 1.26.4 version of Urllib3.

In Python 3.4 and 2.7.9, there is a check_hostname attribute on SSLContext, which will let the SSLContext instance handle checking the hostname in do_handshake. It would be nice for urllib3 to rely on it when possible instead of checking it yourself. I think this complements the rest of the "bag of configuration" using SSLContext as the content of TLS. This can be detected by determining whether the SSLContext object has a check_hostname property. There is a disadvantage, which relies on passing the hostname as part of SSLContext().wrap_socket(server_name=) . Initially this only worked if SNI was enabled in OpenSSL. But even if SNI is not enabled, Python 3.4.3 and 2.7.9 will accept server_name.

solution

1. URLLIB3 drops below urllib3 == 1.25.8

urllib3-lovered-version.jpg

2. Request method plus verification = false parameters

response = requests.request('GET', 'http://xxx.xxxx.com', verify=False)

Direct operation will report the following warning:

InsecureRequestWarning:正在发出未经验证的 HTTPS 请求。强烈建议添加证书验证。请参阅:https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning,

3. Before requesting the request, add the following code to solve the above warning

Urllib3.disable_warnings() 或 Requests.Packages.urllib3.disable_warnings()

4. Turn off the agent

close-agent.png

related articles

Remote anaconda under liunx build/build environment, connect, transplant/copy environment
Python3 Get any post bar, the latest post production word cloud image and store it as markdown

阅读 794

前端与算法
前端与算法系列合集

msy.plus

62 声望
11 粉丝
0 条评论

msy.plus

62 声望
11 粉丝
文章目录
宣传栏