![]() |
set up rest with https - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1) +--- Forum: Lounge (https://forum.codeigniter.com/forumdisplay.php?fid=3) +--- Thread: set up rest with https (/showthread.php?tid=71344) |
set up rest with https - anthos1984 - 08-02-2018 I have set up REST server support https using my own generated certificate. Then I have the client POSTing data using https. But it seems not work. When using http it works. Here the code PHP Code: case "POST": // Used to create a new object on the server (INSERT) I'm sure config_item('cert_path') points to certificate file downloaded from server Tell me if I'm wrong setting up curl. Also, how to know if my clients certificate rejected by server? Is CI reports it in log (server) or log (client)? RE: set up rest with https - jreklund - 08-02-2018 make a var_dump on $rdata for error messages. cert_path should be a local path to a .pem file. RE: set up rest with https - anthos1984 - 08-02-2018 i do log_message('debug', var_export($rdata, TRUE)); The result is 'false' No messages ![]() RE: set up rest with https - jreklund - 08-02-2018 Ok, you got an error then. Use curl_error to see what: http://php.net/manual/en/function.curl-error.php#refsect1-function.curl-error-examples RE: set up rest with https - anthos1984 - 08-02-2018 OK, done. Thanks.. So is use curl_error($ch) to see. I'm using CI4, so i set cert path in .env : app.CertPath = APPPATH.'Cert/livehost.crt' and in the code : curl_setopt($ch, CURLOPT_CAINFO, $config->CertPath); But unfortunately APPPATH not work on .env, curl error says "error setting certificate verify locations" and show plain APPPATH !! It should be changed with 'something/application' So I change on .env : app.CertPath = 'application/Cert/livehost.crt' and in the code : curl_setopt($ch, CURLOPT_CAINFO, ROOTPATH.$config->CertPath); RE: set up rest with https - jreklund - 08-02-2018 I haven't tried CI4, so can't give you any feedback on why that's not working. But at least you can hardcode it for now. |