hyper icon indicating copy to clipboard operation
hyper copied to clipboard

_ssl.c errors

Open KOLANICH opened this issue 8 years ago • 11 comments

en.wikipedia.org -> _ssl.c:733: The handshake operation timed out github.com, google.com, yandex.ru -> SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:749) twitter.com -> SSLEOFError: EOF occured in violation of protocol (_ssl.c:749)

KOLANICH avatar Jul 04 '17 09:07 KOLANICH

In all of these cases it's very hard to know without additional details what's going on. What version of Python and OpenSSL are you using?

Lukasa avatar Jul 04 '17 09:07 Lukasa

Anaconda custom-py36_0 based on 4.4.0-np112py36_1 x86 (32 bit) (just fully updated that version) python 3.6.1.final.0

KOLANICH avatar Jul 04 '17 09:07 KOLANICH

What about OpenSSL?

Lukasa avatar Jul 04 '17 09:07 Lukasa

openssl 1.0.2l (as reported by conda list openssl)

KOLANICH avatar Jul 04 '17 09:07 KOLANICH

Hrm. Can you show me some sample code that reproduces the issue?

Lukasa avatar Jul 04 '17 09:07 Lukasa

https://pastebin.com/GRCYVVEd

KOLANICH avatar Jul 04 '17 10:07 KOLANICH

Hrm, this is not obviously problematic. Are you familiar with Wireshark? If you are, it'd be helpful to see the pcap for one of these failing transactions.

Lukasa avatar Jul 04 '17 14:07 Lukasa

You need to specify a port along with hostname.

--- t.original.py	2017-07-31 14:41:55.000000000 +0300
+++ t.fixed.py	2017-07-31 14:43:29.000000000 +0300
@@ -2,11 +2,13 @@
 from urllib.parse import urlparse
 from hyper import HTTPConnection

+default_port = dict(http=80, https=443)
+
 def makeActualReq(uri, referer=None, maxRedirects=10):
 	if maxRedirects<=0:
 		raise Exception("Redirects limit reached")
 	u=urlparse(uri)
-	with HTTPConnection(u.hostname, secure=(u.scheme=="https")) as conn:
+	with HTTPConnection(u.hostname, port=(u.port or default_port.get(u.scheme.lower())), secure=(u.scheme=="https")) as conn:
 		#print(u.path)
 		conn.request('GET', u.path)
 		resp=conn.get_response()

KostyaEsmukov avatar Jul 31 '17 11:07 KostyaEsmukov

Thank you, it looks like HTTP11Connection should be modified.

KOLANICH avatar Jul 31 '17 14:07 KOLANICH

Thanks for that tip @KostyaEsmukov It helped me here: https://github.com/Lukasa/hyper/issues/408#issuecomment-486232660

peterbe avatar Apr 24 '19 13:04 peterbe

See this comment: https://github.com/Lukasa/hyper/pull/407#issuecomment-486234837

I was running pytest with hyper in Python 3.7 and was getting that SSL warning. But as soon as I installed ndg-httpsclient that (same) SSL error disappeared.

peterbe avatar Apr 24 '19 13:04 peterbe