title: How to make an HTTPS request using cURL?
body: <p>I have 2 php scripts , to send an xml file and catch it. I am using cURL and everything was ok. Now i am trying to do the same but using HTTP over SSL (HTTPS). I have installed a local server with XAMPP and i have set up SSL by following this post : <a href="https://stackoverflow.com/questions/2643462/setting-up-ssl-on-a-local-xampp-apache-server">Setting up SSL on a local xampp/apache server</a> .</p>
  
  <p>I am trying to send the xml file like this :</p>
  
  <pre><code>&lt;?php
    /*
     * XML Sender/Client.
     */
    // Get our XML. You can declare it here or even load a file.
  
  
  
    $xml = file_get_contents("data.xml");
  
  
    // We send XML via CURL using POST with a http header of text/xml.
    $ch = curl_init();
  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
  
    //i use this line only for debugging through fiddler. Must delete after done with debugging.
    curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
  
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://ipv4.fiddler/iPM/receiver.php");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_REFERER, 'https://ipv4.fiddler/iPM/receiver.php');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ch_result = curl_exec($ch);
    echo "Result = ".$ch_result;
    curl_close($ch);
    // Print CURL result.
  ?&gt;
  </code></pre>
  
  <p>I downloaded the new certificate for cURL from here :</p>
  
  <p><a href="http://curl.haxx.se/ca/cacert.pem" rel="nofollow noreferrer">http://curl.haxx.se/ca/cacert.pem</a></p>
  
  <p>I am not sure where i should put the certificate but i put it in my workspace directory of this project.</p>
  
  <p>The problem now is that the XML file is never sent to the receiver. Any ideas?</p>