我收到了以下代码..
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$keystore = '/var/www/html/key.pem';
$url = 'https://myurl';
$keystorepassword = '123';
$key2 = "/var/www/html/public.pem";
$handler = fopen($key2, "r");
$kkey = fread($handler, 8192);
fclose($handler);
$pubkey = openssl_get_publickey($kkey);
openssl_free_key($pubkey);
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($curl, CURLOPT_SSLVERSION,3);
curl_setopt($curl, CURLOPT_SSLCERT, $keystore);
curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keystorepassword);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'data');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result =curl_exec ($curl);
var_dump($result);
if(curl_error($curl)){
$result = curl_error($curl);
var_dump($result);
}
curl_close ($curl);
?>
它返回“无法使用客户端证书(没有找到密钥或错误的密码短语?)”。 如果我评论行“$ pubkey = openssl_get_publickey($ kkey);”,那么curl工作正常。 有没有机会,“某些东西”留在记忆中并卷曲使用它?