简体   繁体   中英

How to pass parameter --cert and --key with CURL PHP?

    $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;

How can i add for this parameter --cert and --key?

If i use curl in console then i can:

curl -k --cert new.crt --key new.key https://example.com/curl.php?option=test

but how can i use this in PHP code?

Try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM