我安装了 XAMPP,我需要测试一些 HTTPS 请求。首先,我尝试配置 XAMPP,以便可以使用 HTTPS 请求。
这就是我所做的:
1) 在 php.ini 文件中,我取消了openssl module
.
2) 在 httpd.conf 文件中,我取消了注释LoadModule ssl_module modules/mod_ssl.so
3)在 httpd-ssl.conf 文件中,我重定向了
SSLCertificateFile "conf/ssl.crt/ipm.crt"
和
SSLCertificateKeyFile "conf/ssl.key/ipm.key
" 到我的 .crt 和 .key 文件。
4) 我将我的 ipm.crt 和 ipm.key 文件放在 apache 文件夹ssl.crt
和ssl.key
XAMPP 中。
5)我通过执行以下操作创建了我的自签名证书:
openssl req -config openssl.cnf -new -out ipm.csr -keyout ipm.pem
openssl rsa -in ipm.pem -out ipm.key
openssl x509 -in ipm.csr -out ipm.crt -req -signkey ipm.key -days 365
现在我正在使用一个脚本来发送一个 XML 文件。我正在使用 cURL,我的代码是:
<?php
/*
* XML Sender/Client.
*/
// Get our XML. You can declare it here or even load a file.
$xml = file_get_contents("data.xml");
// We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd().'/cert/ipm.crt');
curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/ipm.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD,'password');
//I use this line only for debugging through fiddler. Must delete after done with debugging.
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://ipv4.fiddler/iPM/receiver.php");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, 'https://ipv4.fiddler/iPM/receiver.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ch_result = curl_exec($ch);
echo "Result = ".$ch_result;
echo 'Curl error: ' . curl_error($ch);
curl_close($ch);
// Print CURL result.
?>
但我得到了这个错误:Curl error: unable to use client certificate (no key found or wrong pass phrase?)
但是,当我创建证书时,我确实将以下短语作为密码:password
对此事有任何想法吗?