Title: ssl: FileNotFoundError when do handshake
Type: behavior Stage: resolved
Components: SSL Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: Windson Yang, christian.heimes,
Priority: normal Keywords:

Created on 2018-11-27 06:38 by, last changed 2020-10-21 16:43 by christian.heimes. This issue is now closed.

File name Uploaded Description Edit
py-file&output.7z, 2018-12-10 08:30
Messages (7)
msg330491 - (view) Author: ( Date: 2018-11-27 06:38
After upgrade my python from 3.6 to 3.7, one of my program got following error msgs and I suppose it is related to the 'ssl' module:

Traceback (most recent call last):
  File "M:\SUPPOR~1\ONEDAY~1\ODD2\lib\site-packages\urllib3\", line 600, in urlopen
  File "M:\SUPPOR~1\ONEDAY~1\ODD2\lib\site-packages\urllib3\", line 343, in _make_request
  File "M:\SUPPOR~1\ONEDAY~1\ODD2\lib\site-packages\urllib3\", line 839, in _validate_conn
  File "M:\SUPPOR~1\ONEDAY~1\ODD2\lib\site-packages\urllib3\", line 344, in connect
  File "M:\SUPPOR~1\ONEDAY~1\ODD2\lib\site-packages\urllib3\util\", line 357, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "f:\Anaconda3\Lib\", line 412, in wrap_socket
  File "f:\Anaconda3\Lib\", line 853, in _create
  File "f:\Anaconda3\Lib\", line 1117, in do_handshake
FileNotFoundError: [Errno 2] No such file or directory

The background is, the program works all fine under python 3.6.

I actually use the 'requests' lib which use the 'urllib3' inside. I don't know how to fix this so I just report here. I hope some one can help.
msg331306 - (view) Author: Windson Yang (Windson Yang) * Date: 2018-12-07 12:50
I can't reproduce on my laptop. Would you please upload a minimal example?
msg331475 - (view) Author: ( Date: 2018-12-10 08:30
Hi, sorry I can't re-create the enviroment either because the in-house web server I connected to is out of my control. I can't re-create the web server for this exact issue. By the way, the web server is IIS.

Still, I upload my code and the output under both python 3.6.7 and 3.7.1. You can see the code works under python 3.6.7 but broke under 3.7.1.
msg332226 - (view) Author: Windson Yang (Windson Yang) * Date: 2018-12-20 13:24
From the docs

    Changed in version 3.7: Hostname or IP address is matched by OpenSSL during handshake. The function match_hostname() is no longer used. In case OpenSSL refuses a hostname or IP address, the handshake is aborted early and a TLS alert message is send to the peer.

I guess OpenSSL refuse your IP address and port.
msg339823 - (view) Author: ( Date: 2019-04-10 04:02
I am not sure if it is because openssl refuse the ip and port. Like I said, I share both python 3.6 and python 3.7 on one host and they should share one openssl on that machine. The code is same. How can the openssl refuse one with 3.7 and not with 3.6?
msg339921 - (view) Author: ( Date: 2019-04-11 02:55
i am sorry. seems I am wrong. the openssl underlying do not the same.
msg379219 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-10-21 16:43
I'm not able to reproduce the issue. Please re-open this issue if you are still having issue with more recent version of Python and OpenSSL.
Date User Action Args
2020-10-21 16:43:15christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg379219

stage: resolved
2019-04-11 02:55:13josephshi@yahoo.comsetmessages: + msg339921
2019-04-10 04:02:16josephshi@yahoo.comsetmessages: + msg339823
2018-12-20 13:24:44Windson Yangsetmessages: + msg332226
2018-12-10 08:30:56josephshi@yahoo.comsetfiles: + py-file&output.7z

messages: + msg331475
2018-12-07 12:50:16Windson Yangsetnosy: + Windson Yang
messages: + msg331306
2018-11-27 06:38:41josephshi@yahoo.comcreate