Welcome Guest, Not a member yet? Register   Sign In
set up rest with https
#1

(This post was last modified: 08-02-2018, 04:47 AM by anthos1984.)

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)
    if($data === NULL){
        return FALSE;
    } else {
       $fields_string "";
       foreach($data as $key=>$value){
            $fields_string .= $key.'='.$value.'&';
       }
       $fields_string rtrim($fields_string,'&');
       $ch curl_init($url);
       curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
       curl_setopt($ch,CURLOPT_POST,count($data));
       curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
       if($scheme == 'https'){
            curl_setopt($chCURLOPT_SSL_VERIFYPEERTRUE);
            curl_setopt($chCURLOPT_SSL_VERIFYHOST2);
            $cert config_item('cert_path');
            curl_setopt($chCURLOPT_CAINFO$cert);
       }
       $rdata curl_exec($ch);
       $this->responseCode curl_getinfo($ch,CURLINFO_RESPONSE_CODE);
       curl_close($ch);
   }
   break; 

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)?
Reply


Messages In This Thread
set up rest with https - by anthos1984 - 08-02-2018, 04:45 AM
RE: set up rest with https - by jreklund - 08-02-2018, 04:57 AM
RE: set up rest with https - by anthos1984 - 08-02-2018, 05:33 AM
RE: set up rest with https - by jreklund - 08-02-2018, 05:53 AM
RE: set up rest with https - by anthos1984 - 08-02-2018, 06:44 AM
RE: set up rest with https - by jreklund - 08-02-2018, 09:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB