How to send a curl request with pem certificate via PHP?

前端 未结 2 1218
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 19:28

I have a php script in my Apache server that have to send a curl request to a partner\'s server. Partner give me a .pem file that I have to attach to every call I do to its

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 20:02

    I think that you need to use the tmpfile() and stream_get_meta_data.

    $pemFile = tmpfile();
    fwrite($pemFile, "test.pem");//the path for the pem file
    $tempPemPath = stream_get_meta_data($pemFile);
    $tempPemPath = $tempPemPath['uri'];
    curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath); 
    

    Source: This answer here in SO helps me with similar problem.

提交回复
热议问题