"Curl" request on my server is error in SSL certificate

Asked

Viewed 17 times

0

I’m performing a Curl request with PHP on my hosting. However, if I leave the parameter "CURLOPT_SSL_VERIFYPEER" true, the request returns the error "Curl error 60: SSL Certificate: Unable to get local Issuer Certificate".

But my site is with active ssl and functioning normally.

How do I activate this ssl in the answers of Curl requests in my hosting?

My example Curl Code:

$curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_URL => 'https://site.com.br',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $json,
            CURLOPT_HTTPHEADER => array(
                'Content-Type: text/plain'
            ),
        ));
        $response = curl_exec($curl);
        $err = curl_error($curl);
        curl_close($curl);
  • Have you tried using the -k parameter? Example: curl https://site.com.br -k. ref

  • It’s probably not who answers that problem, but who makes the requisition. TLS/SSL works based on authority trust, an authority (such as Digicert, Identrust, Globalsign...) signs the key and generates a certificate. Therefore, whoever establishes the connection (your URL) must also trust the same authority, and for that he must know the public keys. In general, this is called "CA-Bundle". It has the public key of all authorities who are trusted (by a somewhat arbitrary criteria). Finally, set up CA-Bundle as mentioned in the previous link (duplicate).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.