Passing .PEM and .KEY as string in Curl using PHP

前端 未结 4 2014
星月不相逢
星月不相逢 2021-02-12 20:56

I\'ve a CERT and private key files. I\'m using cUrl and PHP to connect to another service. At the moment, I\'ve cert and key in files and it works perfectly fine with following

4条回答
  •  青春惊慌失措
    2021-02-12 21:26

    Using tmpfile() might suffice as a workaround.

    $tempPemFile = tmpfile();
    fwrite($tempPemFile, $pemfile);
    $tempPemPath = stream_get_meta_data($tempPemFile);
    $tempPemPath = $tempPemPath['uri'];
    

    and then:

    curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath); 
    

    but make sure you close it after so the tmp file is delete

    fclose($tempPemFile);
    

提交回复
热议问题