Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter-cURL on self assign certificate [duplicate]

Im using codeigniter-curl extension (https://github.com/philsturgeon/codeigniter-curl) to call API that return Json format data.

a simple code it will return the result etc

$this->curl->simple_get(http://example.com/Json/GetHotDealRedemptionProduct?APIid=888ef4d078ca&Language=en&hash=3709aa6e0efe3c95e955a1981118027a2fde0eddc216b4049e6559af55f50458);

everything seem ok until the URL changed to HTTPS.

In order to call SSL url (self signed certificate), i added these few line above my $this->curl->simple_get.... code.

$this->curl->create($this->url);
$this->curl->ssl(true, 2, 'assets/AIMS-BSN-WEB01.crt'); 

the cacert.pem i saved from the firefox certificate viewer and place it in my web directory. reference: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

and i get this error.

error code: 60
SSL certificate problem: unable to get local issuer certificate

i've searched the answer for a day long,

  1. changed the php.ini setting Amazon S3 on wamp localhost SSL error

  2. put false for CURLOPT_SSL_VERIFYPEER. it return SSL: certificate subject name 'AIMS-BSN-WEB01' does not match target host name 'api.example.com'

all these are not working.

like image 662
Bravo Net Avatar asked Mar 24 '26 01:03

Bravo Net


1 Answers

ok. i manage to solved it by skipping to verify the peer or host of the certification - PHP CURL CURLOPT_SSL_VERIFYPEER ignored

and instead of putting FALSE in CURLOPT_SSL_VERIFYPEER i use 0.

$this->option(CURLOPT_SSL_VERIFYPEER, 0);
$this->option(CURLOPT_SSL_VERIFYHOST, 0);

now it works.

like image 192
Bravo Net Avatar answered Mar 26 '26 16:03

Bravo Net