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

Unable to download Youtube videos - SSL: CERTIFICATE_VERIFY_FAILED #11573

Closed
orion4444 opened this issue Jan 1, 2017 · 13 comments
Closed

Unable to download Youtube videos - SSL: CERTIFICATE_VERIFY_FAILED #11573

orion4444 opened this issue Jan 1, 2017 · 13 comments

Comments

@orion4444
Copy link

@orion4444 orion4444 commented Jan 1, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.12.22. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2016.12.22

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • [X ] Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', 'bestaudio', 'http://www.youtube.com/wat
ch?v=8VFknfOWmHE']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2016.12.31
[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] 8VFknfOWmHE: Downloading webpage
ERROR: Unable to download webpage: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILE
D] certificate verify failed (_ssl.c:600)> (caused by URLError(SSLError(1, '[SSL
: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)'),))
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpa0c7afb5\bu
ild\youtube_dl\extractor\common.py", line 406, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpa0c7afb5\bu
ild\youtube_dl\YoutubeDL.py", line 2001, in urlopen
  File "C:\Python\Python34\lib\urllib\request.py", line 464, in open
  File "C:\Python\Python34\lib\urllib\request.py", line 482, in _open
  File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpa0c7afb5\bu
ild\youtube_dl\utils.py", line 1041, in https_open
  File "C:\Python\Python34\lib\urllib\request.py", line 1185, in do_open

Press any key to continue . . .

---

### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**):
- Single video: http://www.youtube.com/watch?v=8VFknfOWmHE
- Single video: https://www.youtube.com/watch?v=sBfzwPoX_Zw

---

### Description of your *issue*, suggested solution and other information

Unable to download Youtube videos - SSL cert error.
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 1, 2017

Can you watch it in browser in the first place?

Download curl and post the output of curl.exe -v -I "https://www.youtube.com/watch?v=8VFknfOWmHE&gl=US&hl=en&has_verified=1&bpctr=9999999999".

@orion4444
Copy link
Author

@orion4444 orion4444 commented Jan 1, 2017

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\Users\Admin\Documents\curl-7.52.1-win32-mingw\curl-7.52
.1-win32-mingw\bin

C:\Users\Admin\Documents\curl-7.52.1-win32-mingw\curl-7.52.1-win32-mingw\bin>curl
.exe -v -I "https://www.youtube.com/watch?v=8VFknfOWmHE&gl=US&hl=en&has_verified
=1&bpctr=9999999999"

  • Trying 72.195.166.26...

  • TCP_NODELAY set

  • Connected to www.youtube.com (72.195.166.26) port 443 (#0)

  • ALPN, offering h2

  • ALPN, offering http/1.1

  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength

  • successfully set certificate verify locations:

  • CAfile: C:\Users\Admin\Documents\curl-7.52.1-win32-mingw\curl-7.52.1-win32-mi
    ngw\bin\curl-ca-bundle.crt
    CApath: none

  • TLSv1.2 (OUT), TLS handshake, Client hello (1):

  • TLSv1.2 (IN), TLS handshake, Server hello (2):

  • TLSv1.2 (IN), TLS handshake, Certificate (11):

  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):

  • TLSv1.2 (IN), TLS handshake, Server finished (14):

  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

  • TLSv1.2 (OUT), TLS change cipher, Client hello (1):

  • TLSv1.2 (OUT), TLS handshake, Finished (20):

  • TLSv1.2 (IN), TLS handshake, Finished (20):

  • SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305

  • ALPN, server accepted to use h2

  • Server certificate:

  • subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.google.com

  • start date: Dec 15 14:04:15 2016 GMT

  • expire date: Mar 9 13:35:00 2017 GMT

  • subjectAltName: host "www.youtube.com" matched cert's "*.youtube.com"

  • issuer: C=US; O=Google Inc; CN=Google Internet Authority G2

  • SSL certificate verify ok.

  • Using HTTP2, server supports multi-use

  • Connection state changed (HTTP/2 confirmed)

  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0

  • Using Stream ID: 1 (easy handle 0x8c0fc8)

HEAD /watch?v=8VFknfOWmHE&gl=US&hl=en&has_verified=1&bpctr=9999999999 HTTP/1.1

Host: www.youtube.com
User-Agent: curl/7.52.1
Accept: /

  • Connection state changed (MAX_CONCURRENT_STREAMS updated)!
    < HTTP/2 200
    HTTP/2 200
    < content-type: text/html; charset=utf-8
    content-type: text/html; charset=utf-8
    < strict-transport-security: max-age=31536000
    strict-transport-security: max-age=31536000
    < x-xss-protection: 1; mode=block; report=https://www.google.com/appserve/securi
    ty-bugs/log/youtube
    x-xss-protection: 1; mode=block; report=https://www.google.com/appserve/security
    -bugs/log/youtube
    < cache-control: no-cache
    cache-control: no-cache
    < p3p: CP="This is not a P3P policy! See http://support.google.com/accounts/answ
    er/151657?hl=en for more info."
    p3p: CP="This is not a P3P policy! See http://support.google.com/accounts/answer
    /151657?hl=en for more info."
    < x-frame-options: SAMEORIGIN
    x-frame-options: SAMEORIGIN
    < expires: Tue, 27 Apr 1971 19:44:06 EST
    expires: Tue, 27 Apr 1971 19:44:06 EST
    < x-content-type-options: nosniff
    x-content-type-options: nosniff
    < date: Sun, 01 Jan 2017 08:44:53 GMT
    date: Sun, 01 Jan 2017 08:44:53 GMT
    < server: YouTubeFrontEnd
    server: YouTubeFrontEnd
    < set-cookie: VISITOR_INFO1_LIVE=4lrR5C64KFA; path=/; domain=.youtube.com; expir
    es=Fri, 01-Sep-2017 20:37:53 GMT; httponly
    set-cookie: VISITOR_INFO1_LIVE=4lrR5C64KFA; path=/; domain=.youtube.com; expires
    =Fri, 01-Sep-2017 20:37:53 GMT; httponly
    < set-cookie: s_gl=1d69aac621b2f9c0a25dade722d6e24bcwIAAABVUw==; path=/; domain=
    .youtube.com
    set-cookie: s_gl=1d69aac621b2f9c0a25dade722d6e24bcwIAAABVUw==; path=/; domain=.y
    outube.com
    < set-cookie: YSC=NKV2VC4aGKk; path=/; domain=.youtube.com; httponly
    set-cookie: YSC=NKV2VC4aGKk; path=/; domain=.youtube.com; httponly
    < set-cookie: PREF=f1=50000000; path=/; domain=.youtube.com; expires=Fri, 01-Sep
    -2017 20:37:53 GMT
    set-cookie: PREF=f1=50000000; path=/; domain=.youtube.com; expires=Fri, 01-Sep-2
    017 20:37:53 GMT
    < alt-svc: quic=":443"; ma=2592000; v="35,34"
    alt-svc: quic=":443"; ma=2592000; v="35,34"
    < accept-ranges: none
    accept-ranges: none
    < vary: Accept-Encoding
    vary: Accept-Encoding

<

  • Curl_http_done: called premature == 0
  • Connection #0 to host www.youtube.com left intact

C:\Users\Admin\Documents\curl-7.52.1-win32-mingw\curl-7.52.1-win32-mingw\bin>

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 1, 2017

Most likely you have some expired certificates in system store you may want to manually remove.
Or use --no-check-certificate if you don't care.

@dstftw dstftw closed this Jan 1, 2017
@orion4444
Copy link
Author

@orion4444 orion4444 commented Jan 1, 2017

That was it, I had a cert that expired 12/31/2016. For anyone else having the issue, here are the steps that were posted to manually remove a cert:

  1. run certmgr.msc
  2. menu -> action -> find certificates.
  3. choose "look in fields: issued to"
  4. at the "contains" field type "google".
  5. click "find now"
  6. mark all the expired certs (useful to sort by exp. date)
  7. right click and choose "delete"
@dstftw dstftw mentioned this issue Feb 14, 2017
3 of 3 tasks complete
@dstftw dstftw mentioned this issue Mar 2, 2017
4 of 8 tasks complete
@Celthi Celthi mentioned this issue Mar 4, 2017
4 of 8 tasks complete
@dstftw dstftw mentioned this issue May 7, 2017
4 of 8 tasks complete
@dstftw dstftw mentioned this issue Aug 18, 2017
1 of 5 tasks complete
@dstftw dstftw mentioned this issue Dec 30, 2017
5 of 8 tasks complete
@zouhair
Copy link
Contributor

@zouhair zouhair commented Jan 1, 2018

Thank you man, you saved my ass in 2017 too :)

@fabiomb
Copy link

@fabiomb fabiomb commented Jan 6, 2018

excelent advice Orion4444 same error, same fix ;)

@a1iraxa
Copy link

@a1iraxa a1iraxa commented Jan 19, 2018

@orion4444 Thank you. you are a lifesaver. The solution still worked in 2018.

@peixotorms
Copy link

@peixotorms peixotorms commented Feb 3, 2018

I didn't have any expired certificates using certmgr.msc but I did, when using Internet Options->Content->Clear SSL State and Internet Options->Content->Certificates (check all of those tabs).

@dstftw dstftw mentioned this issue Feb 13, 2018
5 of 9 tasks complete
@avih
Copy link

@avih avih commented Jun 27, 2018

That was it, I had a cert that expired 12/31/2016. For anyone else having the issue, here are the steps that were posted to manually remove a cert:

run certmgr.msc
menu -> action -> find certificates.
choose "look in fields: issued to"
at the "contains" field type "google".
click "find now"
mark all the expired certs (useful to sort by exp. date)
right click and choose "delete"

@orion4444 I think I wrote this exact comment, maybe originally on #7309 - and it's not there anymore (I didn't remove it myself). How come it now shows up with your name, and my own comment is gone? did someone edited comments? is it a github bug?

@pzygielo
Copy link

@pzygielo pzygielo commented Jun 27, 2018

@avih - it's there (#7309 (comment)), just show hidden comments.

@avih
Copy link

@avih avih commented Jun 27, 2018

just show hidden comments.

Oh. Thanks :)

@xingheng
Copy link

@xingheng xingheng commented Jan 11, 2019

How about the macOS?

@xingheng
Copy link

@xingheng xingheng commented Mar 7, 2020

After trying all the solutions from current issue and issue 4816, neither of them did work for me.

Here is my final solution, I find the default ca-certification of curl via curl-config --ca, then export SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt" in my shell profile.

It works!

My guess: the youtube-dl package or python didn't find the expected ca-certification file in its default search paths inside.

My environment:

  • Python 3.7
  • Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.