1

I have been trying to gain access to a couple of APIs from two different parties using cURL but have been experiencing a consistent issue. When I submit a request to either party I receive the following error:

SSL certificate problem: self signed certificate in certificate chain

I am attempting to reach these APIs from my localhost which is currently WAMP.

Here is how I am attempting to gain access:

$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if(curl_error($ch)) {
    var_dump(curl_error($ch));
}
curl_close($ch);

var_dump($response);

I am confused as to why I am recieving an error because I can use the following code to access the APIs using file_get_contents()

$opts = [
    "http" => [
        "header" => implode("\r\n", $headers)
    ],
    'ssl' => [
        'verify_peer' => true,
        "verify_peer_name" => true
    ]
];

$context = stream_context_create($opts);

$response = file_get_contents($target_url, NULL, $context);

var_dump($response);

Edit: These requests contain sensitive information so TLS/SSL is a must.

Edit: $target_url = 'https://*3rd Party API*/target';

Edit: there is no proxy

Newb 4 You BB
  • 1,205
  • 1
  • 11
  • 30
  • can you clarify if `$target_url` is your WAMP server or if it is a 3rd party api and if the url starts with http or https? – brein Jan 04 '21 at 00:30
  • https://stackoverflow.com/questions/13690173/post-request-with-a-self-signed-certificate – user2182349 Jan 04 '21 at 01:01

0 Answers0