$ch = curl_init("www.example.com/curl.php?option=test");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
如何为此参数添加--cert和--key?
如果我在控制台中使用curl,那么我可以:
curl -k --cert new.crt --key new.key https://example.com/curl.php?option=test
但我如何在PHP代码中使用它?
答案 0 :(得分:1)
尝试
curl_setopt($ch, CURLOPT_SSLCERT, 'new.crt');
curl_setopt($ch, CURLOPT_SSLKEY, 'new.key');