Can't CURL HTTPS URL on WAMP but works on remote server using BASH
curl, php, ssl
Solution
I think I found the answer, the issue is your curl request could not verify the ssl peer. Windows does not automatically have a CA certificate to do the validation against.
So here is what I did to get my https requests via curl fixed for wamp. download the cacert.pem file here http://curl.haxx.se/docs/caextract.html and place it in your PHP folder, mine was located at: `C:\wamp\bin\php\php5.5.12`
Now open the php.ini file and find the line starting with `; curl.cainfo =`
un-comment that line "remove the ; in front" and add the absolute path of the cacert.pem file. Mine looked something like this: `curl.cainfo = C:\wamp\bin\php\php5.5.12\cacert.pem`
Now restart wamp and voila! I can happily open https protocols via curl on wamp.
Problem
Here's the BASH command I'm using on my remote server - ``` curl -i -H "Content-Type: application/json" -H "Authorization: USERNAME:PASSWORD" "https://api7.publicaster.com/Rest/Ping.svc/?format=json" ``` Here's the code on my PHP script which I run on a WAMP local test environment to request the same information. ``` header("Content-Type: application/json"); $encrypted_account_id = 'USERNAME'; $api_password = 'PASSWORD'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://api7.publicaster.com/Rest/Ping.svc/?format=json"); $headers = array(); $headers[] = 'Content-type: application/json'; $headers[] = 'Authorization: $encrypted_account_id:$api_password'; curl_setopt($ch, CURLOPT_HEADER, $headers); $server_output = curl_exec($ch); curl_close($ch); print_r($server_output); ``` If on my PHP script I request the HTTP site then it returns - ``` HTTP/1.1 401 Unauthorized Cache-Control: private ``` If on my PHP script I request the HTTPS site then it just returns blank. I do have a self-signed SSL certificate and SSL is enabled, I can access HTTPS portions of my WAMP server but I am given a warning. I can't figure out if this was an issue with my code or my WAMP server. Any ideas? If I add the following to my code and try to CURL the HTTPS address I at least receive a response but it's the Unauthorized CC: private error - ``` curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); ```