cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

Hi everyone,

I am getting the following error: 

C:\Python36\Dartfish\Scripts\python.exe C:/Workspace/COC-Dartfish/Dartfish/Dropbox_Download.py SBL

Traceback (most recent call last):
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\connection.py", line 370, in connect
    ssl_context=context,
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\util\ssl_.py", line 377, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Program Files\Python36\lib\ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "C:\Program Files\Python36\lib\ssl.py", line 817, in __init__
    self.do_handshake()
  File "C:\Program Files\Python36\lib\ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "C:\Program Files\Python36\lib\ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python36\Dartfish\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Python36\Dartfish\lib\site-packages\urllib3\util\retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Max retries exceeded with url: /2/files/download (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Workspace/COC-Dartfish/Dartfish/Dropbox_Download.py", line 95, in <module>
    dd = DropBoxDownload(args.sportscode)
  File "C:/Workspace/COC-Dartfish/Dartfish/Dropbox_Download.py", line 39, in __init__
    self.process_entries()
  File "C:/Workspace/COC-Dartfish/Dartfish/Dropbox_Download.py", line 84, in process_entries
    dbx.files_download_to_file(local_file, entry.path_lower)
  File "C:\Python36\Dartfish\lib\site-packages\dropbox\base.py", line 1238, in files_download_to_file
    None,
  File "C:\Python36\Dartfish\lib\site-packages\dropbox\dropbox.py", line 274, in request
    timeout=timeout)
  File "C:\Python36\Dartfish\lib\site-packages\dropbox\dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "C:\Python36\Dartfish\lib\site-packages\dropbox\dropbox.py", line 449, in request_json_string
    timeout=timeout,
  File "C:\Python36\Dartfish\lib\site-packages\requests\sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Python36\Dartfish\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python36\Dartfish\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python36\Dartfish\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Max retries exceeded with url: /2/files/download (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

Process finished with exit code 1

 

To give you context, I am using a python library to download some files, this seemed to be working however I am not sure when it stopped working. However, I just tried this program on my windows 10 machine, and also a spare Linux machine with the same error. 

I have tried the different solutions provided, but none of them seemed to have worked. If someone can help me out, that'd be really awesome. Appreciate your help. 


Running:

dropbox 10.2.0
Python 3

1 Accepted Solution

Accepted Solutions
Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

Dropboxer
Dropboxer

That shouldn't be the issue here. The files_download_to_file method does allow you to download files from shared folders. Also, the error you're getting indicates an issue establishing the secure TLS connection with the Dropbox API servers, which occurs before the Dropbox API itself validates the call or its parameters anyway.

View solution in original post

8 Replies 8
Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

It should say 3.6 instead of Python 3. 

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

For context here's the code I am running

dbx = dropbox.Dropbox("MY TOKEN!!")
result = dbx.files_list_folder("", recursive=True)
while result.has_more:
result = dbx.files_list_folder_continue(result.cursor)
for entry in result.entries:
Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

Dropboxer
Dropboxer

I see from the stack trace that this error is occurring during files_download_to_file. I just gave that, as well as the other methods you included in the code snippet, a try with Python 3.6 and v10.2.0 of the Dropbox Python library on Windows though and it worked fine for me.

 

The error you're getting would seem to indicate that the Dropbox API servers aren't being served with a valid certificate, however that is not the case.

 

Is there anything on your network connection, e.g., a proxy, firewall, anti-virus, or other such software that may be interfering with your connection to the Dropbox API servers? For the files_download_to_file method in particular, it would be to the content.dropboxapi.com host.

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

Hi Greg,

I am doing some research on my own on the side, the folder that i want to access is a shared folder, does that make any difference? Could that be the reason why I am not able to access the file?

 

Thanks and Regards,

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

Dropboxer
Dropboxer

That shouldn't be the issue here. The files_download_to_file method does allow you to download files from shared folders. Also, the error you're getting indicates an issue establishing the secure TLS connection with the Dropbox API servers, which occurs before the Dropbox API itself validates the call or its parameters anyway.

View solution in original post

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

This is really confusing now, so I am able to download these files manually, meaning going onto Dropbox from the browser and accessing the file and downloading them. However, I can't do it using python. 

I have tried everything, with VPN, without VPN, etc etc. Is there a way for me to manually add the certificate somehow for the handshake to happen?

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

Dropboxer
Dropboxer

The Dropbox website uses a different host than the Dropbox API, so unfortunately that's not a good test for this issue.

 

The Dropbox Python SDK already includes and uses the correct certificates for the Dropbox API servers.

Highlighted

Re: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

New member | Level 2
New member | Level 2

Hi Greg, 

There seems to be some firewall or some other permissions that were placed on the laptop by work, which caused us this issue. I tested the exact same program on my own personal laptop and it did the job that it was supposed to do. 

 

 

Thank you for your assistance, I truly appreciate your help. Have a great weekend. 

MN

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?