0

I'm need to know how to write the follow CURL command in PHP, I tried it from various modes and I searched in many articles here in the StackOverflow and I tried to adaptate the code but nothing is really working:

curl -v --insecure --cert public-certified-with-chain.pem --key private-key.key -nodes GET "MY_URL" "accept: */*"

I managed to reach this stage, but it doesn't work:

   $ch = curl_init();

   curl_setopt($ch, CURLOPT_URL, 'https://...');
   curl_setopt($ch, CURLOPT_VERBOSE, 1);

   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);

   $result = curl_exec($ch);

   echo $result;

The code above is simplified, it return a result, but still showing "Unauthorized".

How to adapt it to attach the files?

UserOfStackOverFlow
  • 108
  • 1
  • 3
  • 14

1 Answers1

1

curl's --cert option corresponds to CURLOPT_SSLCERT, which isn't present in your PHP code.

I suggest you add --libcurl sample.c to your command line to get a code template (in C), that you then can translate to PHP.

Also, the command line shown in the question doesn't appear to be a fully working curl command line.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222