6
我需要帮助来重写这个PHP curl代码(在一个文件中使用一个* .pem文件--CA证书,客户端证书,私钥):在单独的文件中使用curl在“CA证书,客户端证书和私钥”
curl_setopt($curl, CURLOPT_URL, $this->url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSLCERT, $this->keystore);
curl_setopt($curl, CURLOPT_CAINFO, $this->keystore);
curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $this->keystorepassword);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
所以它可以使用CA证书,客户端证书并在不同的文件私钥。
如该命令行示例:
curl -d "var1=value1&var2=value2&..." -G -v --key key.pem --cacert ca.pem --cert client.pem:xxxxxx https://www.somesite.com/page
非常感谢你,我一回到家就试试这个。 – somerandomusername
我希望他回家好吗。 – phatfingers
啊哈!我花了几个小时才找到这个注释很好的示例,以便理解'CURLOPT_CAINFO'等同于'--cacert'标志。我笨拙地使用'CURLOPT_SSLCERT' - 现在看起来很明显。荣誉,@DaveRandom。 –