title: Using Libcurl library for file download
body: <p>I am trying to implement autoupdate by downloading the update files from a share link in Dropbox or google drive. At first, I used windows API function URLDownloadToFile() to download public files from the web. It works fine, but when I used it for cloud files, it did not download the file. It rather get an HTML file that when opened with a browser, I can download the file using the browser.</p>
  
  <p>So, I shifted to using Libcurl library and followed their tutorial. I always received error</p>
  
  <blockquote>
    <p>(60) : CURL_PEER_FAILED_VERIFICATION.</p>
  </blockquote>
  
  <p>I followed the example at <a href="https://curl.haxx.se/libcurl/c/url2file.html" rel="nofollow noreferrer">https://curl.haxx.se/libcurl/c/url2file.html</a>. And tried to get same public file I already downloaded the windows API and still received same error. So I know it is not related to server authentication or similar issues.</p>
  
  <p>Here is my download function using both windows api and Libcurl:</p>
  
  <pre><code>static size_t write_data (void *ptr,size_t size,size_t nmemb,void* stream)
  {
    size_t written = fwrite (ptr,size,nmemb,(FILE *) stream) ;
    return written ;
  } /* write_data */
  
  
  int DownloadFile ()
  {
    static const char FileURL[] = "https://www.pexels.com/photo/618608/download/?search_query=park&amp;tracking_id=6qgsqm6nzau" :
    static char TargetURL[]  = "D:\\Download\\DownloadURL\\Test.jpg" ;
    static char TargetCURL[] = "D:\\Download\\DownloadCURL\\Test.jpg" ;
  
    // Download the file using windows function into DownloadURL folder
    URLDownloadToFile (nullptr,FileURL[2],TargetURL,0,nullptr) ; // OK
  
    // Download the file using curl library into DownloadCURL folder
    if (auto curl = curl_easy_init ()) {
        auto fp = fopen (TargetCURL,"wb") ;
        curl_easy_setopt (curl,CURLOPT_URL,FileURL[1]) ;
        curl_easy_setopt (curl,CURLOPT_FAILONERROR,1) ;
        curl_easy_setopt (curl,CURLOPT_WRITEDATA,fp) ;
  
        /* Perform the request, res will get the return code */
        auto res = curl_easy_perform (curl) ;                     // Always Fail
  
        fclose (fp) ;
        curl_easy_cleanup (curl) ;
    } /* if (auto curl = curl_easy_init ()) */
  
    return true ;
  
  } /* Download */
  </code></pre>
  
  <p>My system is running Windows 10 x64. I use Visual Studio 2017, Libcurl revision 7.67 with openSSL.</p>
  
  <p>Can anyone help me figure out what is missing?</p>