1

I get this error when trying to run my program:

Traceback (most recent call last):
  File "C:/Users/Adasli199/Desktop/Minetek-Testy-Stuff/tools/soldering-iron.py", line 400, in <module>
    MCVersionRegEx = cacheMCVersions()
  File "C:/Users/Adasli199/Desktop/Minetek-Testy-Stuff/tools/soldering-iron.py", line 141, in cacheMCVersions
    feeddata = opener.open(request).read()
  File "C:\Python27\lib\urllib2.py", line 404, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 422, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "C:\Python27\lib\urllib2.py", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error>

I am trying to get some data data to help with processing my RegEx command in another part of the code, here is the function that it is referencing to which throws the error.

import httplib
import urllib2

def cacheMCVersions():
    request = urllib2.Request('https://mcversions.net/')
    request.add_header('User-Agent', 'SolderingIron/1.0 +http://tetrarch.co/') # identify ourselves so we don't get blocked
    opener = urllib2.build_opener()
    feeddata = opener.open(request).read()

There is some more regex code after this to interpret the data but I feel this is all that is needed to resolve the issues. At the time of running, https://mcversions.net/ was up and still is as far as I am aware, which is what makes this error even more strange.

Adam Griffiths
  • 680
  • 6
  • 26
  • 60
  • The server only supports TLS 1/1.1/1.2 and it works when connecting with Python 3.4, so i suppose the problem lies in the supported SSL/TLS versions in Python 2.7 – cg909 Sep 22 '15 at 18:14
  • which Python version do you use exactly? 2.7.9? – cg909 Sep 22 '15 at 19:54
  • No, I'm using Python 2.7.10 – Adam Griffiths Sep 22 '15 at 20:39
  • I couldn't reproduce your error with 2.7.10 (as downloaded from python.org) but I get the same error with 2.7.9. Are you sure you use 2.7.10? Does ssl.SSLContext exist? – cg909 Sep 28 '15 at 16:40

1 Answers1

0

urllib is broken on python 2.7.9 and lower for https requests.

Install python 2.7.10 inside a virtual enviornment

and it should work. You may need to install libssl-dev or openssl depending on your linux platform.

Community
  • 1
  • 1
MohitC
  • 4,541
  • 2
  • 34
  • 55