0

I'm trying to make a simple phone call using Twilio, however, I keep getting some sort of certificate error - Error SSL certificate problem: unable to get local issuer certificate whenever I run the function which attempts to make the phone call. I looked around and read that my local PC certificates must be outdated or something, hence why I'm getting the error. The problem is that I'm using Windows 7 and most tutorials showing how to fix the error are for Linux. Is there an easy way to fix that problem in Windows? I'm also using Apache with MAMP.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Twilio\Rest\Client;

class CallController extends Controller
{
    public function test(Request $request){
        $accountSid = "xxxxxxxxxxxxxxxxxxxxxxx";
        $authToken = "xxxxxxxxxxxxxxxxxxxxxxxx";

        $client = new Client($accountSid, $authToken);

        try {
            $call = $client->calls->create("+xxxxxxxxxxxxx", "+xxxxxxxxxxxxx", array("url" => "http://demo.twilio.com/docs/voice.xml"));
        } catch (\Exception $e) {
            echo "Error " . $e->getMessage();
        }
    }
}
Onyx
  • 5,186
  • 8
  • 39
  • 86
  • Change url to `https` – train_fox Mar 09 '21 at 12:07
  • @train_fox In the try-catch block? I did and I get the same error. – Onyx Mar 09 '21 at 12:14
  • OK then it must be your certificate. Perhaps you should set ssl for your local apache. – train_fox Mar 09 '21 at 12:16
  • @train_fox That's the thing, I'm trying to install a certificate through certbot right now but it seems so confusing, especially on windows. – Onyx Mar 09 '21 at 12:18
  • Yes it is very complicated to setup certificate. I remember that :D My suggestion is this, try to use laradock if it is possible to use docker. Then you should set the config and it is going to setup certificate for you without headache. – train_fox Mar 09 '21 at 12:24

1 Answers1

1

Open up your php.ini, find and change these two lines

curl.cainfo="C:/location to .pem"
openssl.cafile="C:/location to .pem"

You can download the certificates from https://curl.se/docs/caextract.html

Source: PHP - SSL certificate error: unable to get local issuer certificate

Musti
  • 470
  • 2
  • 11