0

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]);
    }
      
}

2 Answers 2

0

may be your development server running without SSL ("http" instead of "https") some API required request from https instead of http

0

Please check this answer: https://stackoverflow.com/questions/21187946/curl-error-60-ssl-certificate-issue-self-signed-certificate-in-certificate-cha

Give it a try and let us know if it works.

1
  • Just to reiterate the answer that has been linked above. The API call looks like a part of an ERP integration so I would not be surprised if there are additional calls that need to be made, such as those containing customer data. In which case there is even more reason to ensure that the connection is secured correctly otherwise there may be legal ramifications in terms of GDPR or other PII protections in your local area.
    – Craig
    Oct 14, 2021 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.