php 微信退款证书支持CURL字符串证书传输
//生成临时路径 public function getTmpPathByContent($content) { static $tmpFile = null; $tmpFile = tmpfile(); fwrite($tmpFile, $content); $tempPemPath = stream_get_meta_data($tmpFile); return $tempPemPath['uri']; }
调用实例
$cert_pem='1111';//证书里面的内容 $key_pem='2222';//证书里面的内容 $cert = "-----BEGIN CERTIFICATE-----\n" . wordwrap($cert_pem, 64, "\n", true) . "\n-----END CERTIFICATE-----"; if (!$cert) { throw new ApiException('您使用的apiclient_cert证书格式错误,请检查配置'); } $key = "-----BEGIN PRIVATE KEY-----\n" . wordwrap($key_pem, 64, "\n", true) . "\n-----END PRIVATE KEY-----"; if (!$pem) { throw new ApiException('您使用的apiclient_key证书格式错误,请检查配置'); } $path1 =$this->getTmpPathByContent($cert);//获取临时路径 $path2 =$this->getTmpPathByContent($key);//获取临时路径 //开始测试一下 var_dump(file_get_contents($path1));//读取路径里面的内容 var_dump(file_get_contents($path2));//读取路径里面的内容
代码改变世界!