Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error [SSL: CERTIFICATE_VERIFY_FAILED] - Python 2.7.9 #176

Open
kovitimi opened this issue Feb 28, 2015 · 13 comments
Open

error [SSL: CERTIFICATE_VERIFY_FAILED] - Python 2.7.9 #176

kovitimi opened this issue Feb 28, 2015 · 13 comments

Comments

@kovitimi
Copy link

Using Pyhton 2.7.9 on Windows7 after using the following command:

coursera-dl -u [email protected] -p XXX -d C:\Coursera algs4partI-007

I receive the following error message:

- Downloading  https://class.coursera.org/algs4partI-007/lecture/download.mp4?lecture_id=62 None
- failed:  https://class.coursera.org/algs4partI-007/lecture/download.mp4?lecture_id=62 <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>

I tried with different courses, and the other files except for the videos do download, but neither of the videos does.

I am new to using Python, so I would be really grateful if you could walk me through the solution step-by-step.

Thank you

@macedd
Copy link

macedd commented Mar 26, 2015

Got something similar: handshake failure

Coursera-dl v3.1.1 (html.parser)
Logging in as '[email protected]'...
Traceback (most recent call last):
  File "/usr/local/bin/coursera-dl", line 9, in <module>
    load_entry_point('coursera-dl==3.1.1', 'console_scripts', 'coursera-dl')()
  File "/usr/local/lib/python2.7/dist-packages/courseradownloader/courseradownloader.py", line 648, in main
    d.login(args.course_names[0])
  File "/usr/local/lib/python2.7/dist-packages/courseradownloader/courseradownloader.py", line 133, in login
    res = opener.open(req)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 442, in error
    result = self._call_chain(*args)

...

  File "/usr/lib/python2.7/urllib2.py", line 629, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 1] _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure>

And here is how the request looked like

{
    '_Request__r_type': '//www.coursera.org/login?course_id=974076&r=https%3A%2F%2Fclass.coursera.org%2Fdesignbiz-002%2Flecture&user_action=class&topic_name=Design%20Thinking%20for%20Business%20Innovation',
    '_Request__original': 'https: //www.coursera.org/login?course_id=974076&r=https%3A%2F%2Fclass.coursera.org%2Fdesignbiz-002%2Flecture&user_action=class&topic_name=Design%20Thinking%20for%20Business%20Innovation',
    'data': None,
    '_tunnel_host': None,
    'host': 'www.coursera.org',
    'origin_req_host': 'class.coursera.org',
    'headers': {

    },
    '_Request__fragment': None,
    'timeout': <objectobjectat0x7feb545070a0>,
    '_Request__r_host': '/login?course_id=974076&r=https%3A%2F%2Fclass.coursera.org%2Fdesignbiz-002%2Flecture&user_action=class&topic_name=Design%20Thinking%20for%20Business%20Innovation',
    'unredirected_hdrs': {
        'Host': 'www.coursera.org',
        'Cookie': '__204u=123XYZ',
        'User-agent': 'Python-urllib/2.7'
    },
    'unverifiable': True,
    'type': 'https',
    'port': None,
    'redirect_dict': {
        'https: //class.coursera.org/designbiz-002/lecture': 1,
        'https: //www.coursera.org/login?course_id=974076&r=https%3A%2F%2Fclass.coursera.org%2Fdesignbiz-002%2Flecture&user_action=class&topic_name=Design%20Thinking%20for%20Business%20Innovation': 1
    }
}

@danmbox
Copy link

danmbox commented Mar 29, 2015

urllib2.URLError: <urlopen error [Errno 1] _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure> here on mechanize branch

@david-solis
Copy link

I had this issue on OS X 10.10.2, Python 2.7.6 and OpenSSL 0.9.8zc, coursera-dl version 2.0.2.

I fixed this handshaking issue by:

  1. Installing a new OpenSSL version - 1.0.2a 19 Mar 2015
  2. Compiling and installing the cryptography package linked against the new OpenSSL version
  3. Installing requests package with SNI support

Reference:
OpenSSL 1.0.1 Branch Release notes

  • Add TLS padding extension workaround for broken servers

@danmbox
Copy link

danmbox commented Mar 31, 2015

@david-solis, are you on the mechanize branch or the requests branch? I think the official one is mechanize (since there were download problems with requests)

@ICodeEverything
Copy link

On windows, I was able to fix this by upgrading to Python 2.7.9, which has ssl3 disabled for POODLE.

@danmbox
Copy link

danmbox commented Apr 5, 2015

Hm... Running python 2.7.9 (from Ubuntu Vivid via Docker) fixes the problem under Linux

@roncanepa
Copy link

upgrading to 2.7.9 fixed the issue on OSX 10.10, too.

@poluekt
Copy link

poluekt commented Apr 5, 2015

it also works for win7.

 On Sunday, April 5, 2015 3:13 PM, roncanepa <[email protected]> wrote:

upgrading to 2.7.9 fixed the issue on OSX 10.10, too. —
Reply to this email directly or view it on GitHub.

@kvsriram9
Copy link

Hi
How to upgrade to Python2.7.9 on Ubuntu 14.04? Is it a simple download of Python2.7.9.tgz, then extract, ./configure, make and make install? Any other care that needs to be taken care off?

Sorry for the silly question, I am a novice in both Ubuntu and Python!

@rubenve
Copy link

rubenve commented Apr 25, 2015

Upgrading to Python 2.7.9 on my Yosemite system didn't fix it for me. I've also upgraded OpenSSL to 1.0.2a and installed the Cryptography package, but still no dice. Any ideas?

Rubens-MacBook-Pro:Coursera Lectures ruben$ python -V
Python 2.7.9

Rubens-MacBook-Pro:Coursera Lectures ruben$ openssl version -a
OpenSSL 1.0.2a 19 Mar 2015
built on: reproducible build, date unspecified
platform: darwin64-x86_64-cc
options: bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: clang -I. -I.. -I../include -fPIC -fno-common -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/local/etc/openssl"

@danmbox
Copy link

danmbox commented Apr 25, 2015

vagrant up ubuntu-15.04?

@roncanepa
Copy link

Here's my info, @rubenve , in case it helps.

OSX 10.10.2
OSX command line tools 6.2 (haven't updated to 6.3 yet)

 openssl version -a
OpenSSL 0.9.8zc 15 Oct 2014
built on: Nov 12 2014
platform: darwin64-x86_64-llvm
options:  bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) blowfish(idx)
compiler: -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DMD32_REG_T=int -DOPENSSL_NO_IDEA -DOPENSSL_PIC -DOPENSSL_THREADS -DZLIB -mmacosx-version-min=10.6
OPENSSLDIR: "/System/Library/OpenSSL"
python --version
Python 2.7.9

I installed python through homebrew, so maybe that had something to do with it:

brew info python
python: stable 2.7.9 (bottled), HEAD
https://www.python.org
/usr/local/Cellar/python/2.7.9 (4863 files, 79M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/python.rb
==> Dependencies
Build: pkg-config ✔
Required: openssl ✔
Recommended: readline ✔, sqlite ✘, gdbm ✔

(homebrew installed openssl 1.0.2a-1, as well, but openssl version -a gives OpenSSL 0.9.8zc 15 Oct 2014)

I run everything in virtualenvs, but here are my versions of coursera-dl dependencies:

pip freeze
beautifulsoup4==4.3.2
coursera-dl==3.1.1
mechanize==0.2.5
requests==2.3.0
six==1.7.3

Hopefully something in here will help.

@rubenve
Copy link

rubenve commented Apr 25, 2015

@danmbox I could do that, but I prefer getting it to work natively.

@roncanepa Thanks! That did end up helping me. I've just unstalled python 2.7 that shipped with OSX. Then install python 2.7.9 through homebrew. I then reverted my openssl version back to 0.9.8zf, reinstalled coursera-dl and then it worked. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants