You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Synk's avatar
Synk
Explorer | Level 3
7 months ago

Upload API issue

Hi everybody,
I'm using Dropbox API in my web application to upload files to Dropbox via PHP code.

I've been using this procedure for a long time, but today I got an upload error:
"Failed to upload in Dropbox: URL Error: SSL certificate problem: self signed certificate in certificate chain - HTTP Error: 0".

I'm using the following settings:

        $ch = curl_init('https://content.dropboxapi.com/2/files/upload');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
        curl_setopt($ch, CURLOPT_CAINFO, $_SERVER['DOCUMENT_ROOT'] . "certificate_path/cacert.pem");
        curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
        curl_setopt($ch, CURLOPT_PUT, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        curl_setopt($ch, CURLOPT_INFILE, $fp);
        curl_setopt($ch, CURLOPT_INFILESIZE, $size);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


I tried to download a new cacert.pem, but the upload still fails.
I also tried to disable the SSL, but unsuccessfully.

Any suggestions would be really appreciated,
Thank you very much

  • Synk Здравко is correct; the Dropbox API requires TLS (v1.2 in particular, currently), and is currently being served with a valid certificate (from DigiCert). You generally shouldn't need to configure anything manually to be able to connect to that; the default is usually sufficient. We recommend against disabling the verification, as that may make you susceptible to certain types of security issues.

     

    As for why this started occurring, you may want to check if there's anything on your network connection, such as a proxy, VPN, firewall, or other security software that may be interfering with your connections to the Dropbox servers.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Synk wrote:

    ...
    I tried to download a new cacert.pem, but the upload still fails.
    ...


    Hi Synk,

    Why at all do you need explicit certificate set?! All Dropbox sites (including all API domains) are certified by DigiCert. 🙂 You don't need to set anything. If by any chance you need to connect some self signed domain, do it on that connection only. You don't need to change that for all connections (including Dropbox API related).

    Good luck.

    • Synk's avatar
      Synk
      Explorer | Level 3

      Hi Здравко ,
      Thank you very much for your reply.

      I need to keep SSL for security reason. So if I don't explicitly set a certificate, it doesn't work.

      if I set VERIFYPEER = FALSE, the upload actually works. But I believe this is not secure? Otherwise what's the purpose of this option?

      I don't understand why I started to receive this error from this month. I've been using the upload API for over 10 years already with a generic cacert.pem file, and it has always worked correctly. I also tried to download a new version of cacert.pem, but nothing changed...

      Thanks,
      Kind regards

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        Synk wrote:

        ...
        I need to keep SSL for security reason. So if I don't explicitly set a certificate, it doesn't work.
        ...


        Synk, As seems you have misinterpret my comment. I never said  to turn your SSL off neither SSL verification! To be more precise Dropbox uses TLS, by the way. That what I take in mind is that a typical setup comes with all most popular basic certificates preset (including DigiCert - the one used by Dropbox). Usually you don't need to add/include such a certificate since its there already. If this is not true for you, check your server setup configuration. I doubt somebody here can lead you to custom setup configuration issue - this is something very specific. Find how you have turned that certificate out and revert back; that's it.

        Have a nice day.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Synk Здравко is correct; the Dropbox API requires TLS (v1.2 in particular, currently), and is currently being served with a valid certificate (from DigiCert). You generally shouldn't need to configure anything manually to be able to connect to that; the default is usually sufficient. We recommend against disabling the verification, as that may make you susceptible to certain types of security issues.

     

    As for why this started occurring, you may want to check if there's anything on your network connection, such as a proxy, VPN, firewall, or other security software that may be interfering with your connections to the Dropbox servers.

    • Synk's avatar
      Synk
      Explorer | Level 3

      Hi,
      Thanks to both of you Здравко and Greg-DB .
      It was actually a proxy issue, and I had the update the certificates accordingly with the new proxy configuration.

      Thanks for your support,
      Cheers

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,883 PostsLatest Activity: 6 hours ago
326 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!