I am working on a module that will send CURL requests to the external APIs of a CRM. I am getting an error in my exception log like main.CRITICAL: Error Curl {"exception":"[object] (Exception(code: 0): SSL certificate problem: self signed certificate at /httpdocs/vendor/magento/framework/HTTP/Client/Curl.php:427)"} [] does anyone have any idea why is this appening? And how can I solve this issue?
request format
$url="https://sample.com:8000/burst/int/so/control/salesProcess";
$authorization = "Authorization: Bearer vr5HmMkzlxKE70W1y4MibiJUusZwZC25NOVBEx3BD1";
//$headers = ["Content-Type" => "application/json", "Content-Length" => "200", $authorization];
$headers = ["Content-Type" => "application/json", "Accept" => "application/json", "Content-Length" => "200", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => 1, $authorization ,"CURLOPT_CONNECTTIMEOUT"=>120, "CURLOPT_SSL_VERIFYPEER"=>false];
$params = ' {
"ApiContext": {
"application": "ecommerce",
"applicationId": "123456789",
"txnid": "STOCK_ISSUE",
"txprotocol": "SYNC",
"version": "1.0",
"createdOn": "19-jul-20 12:06:10",
"correlationid": "ABCD-12345"
},
"ApiMandatoryParams": {
"sales_issue": '.json_encode($result).
'},
"ApiAdditionalParams": {}
}';
//if the method is get
$this->curl->get($url);
$this->curl->setHeaders($headers);
$this->curl->post($url, $params);
//response will contain the output in form of JSON string
$response = $this->curl->getBody();
// $responseArr = $response->__toArray();
$em = array();
$this->logger->addDebug($response,$em);
}
catch (Exception $e) {
$this->logger->critical('Error Curl', ['exception' => $e]);
}
}