【问题标题】:How to pass parameter --cert and --key with CURL PHP?如何使用 CURL PHP 传递参数 --cert 和 --key?
【发布时间】:2014-04-27 20:31:20
【问题描述】:
    $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 代码中使用它呢?

【问题讨论】:

    标签: php curl ssl


    【解决方案1】:

    试试

    curl_setopt($ch, CURLOPT_SSLCERT, 'new.crt');
    curl_setopt($ch, CURLOPT_SSLKEY, 'new.key');
    

    【讨论】:

    • 我收到cURL Error #": "could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)
    猜你喜欢
    • 2018-07-08
    • 2018-03-25
    • 2011-12-19
    • 1970-01-01
    • 2016-07-25
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多