XAMPP をインストールしましたが、いくつかの HTTPS リクエストをテストする必要があります。まず、HTTPS リクエストを使用できるように XAMPP を構成しようとしました。
これは私がしたことです:
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
この問題に関するアイデアはありますか?