問題描述
我正在嘗試使用以下代碼設置 Soap 客戶端:
I'm trying to set up a Soap client with the following code:
<?php
$wsdl = 'https://domain.com/?wsdl';
$endpoint = 'https://domain.com';
$certificate = dirname(__FILE__) . '/CertWithKey.pem';
$password = 'pwd';
$options = array(
'location' => $endpoint,
'keep_alive' => true,
'trace' => true,
'local_cert' => $certificate,
'passphrase' => $password,
'cache_wsdl' => WSDL_CACHE_NONE
);
try {
$soapClient = new SoapClient($wsdl, $options);
} catch(Exception $e) {
var_dump($e);
}
我得到了一個帶有 .crt 認證文件的 .p12 密鑰文件.使用 openssl 我已將 .p12 文件轉換為 .pem 文件,然后將其與 .crt 文件合并.CertWithKey.pem 看起來不錯,文件中有兩個證書塊.
I was given a .p12 key-file with a .crt certification file. Using openssl I've converted the .p12-file to a .pem-file and then merged it with the .crt-file. The CertWithKey.pem looks good to me, two certificate-blocks are in the file.
無論我嘗試做什么,我總是收到一個異常消息 SOAP-ERROR: Parsing WSDL: 無法從https://domain.com/?wsdl"加載:加載失敗外部實體https://domain.com/?wsdl"
.
No matter what I try to do, I keep getting an exception with the message SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://domain.com/?wsdl' : failed to load external entity "https://domain.com/?wsdl"
.
在與遠程方通話后,他們承認有請求進入,但他們記錄了此錯誤:ssl 握手被系統中斷 [提示:在瀏覽器中按下停止按鈕?!]
.
After phoning with the remote party they acknowlegde that a request is coming in but they're logging this error: ssl handshake interrupted by system [hint: stop button pressed in browser?!]
.
由于目前我在網上沒有找到任何有用的信息,所以我想請教大家對此事的一些見解.
Since I didn't find any useful information on the net so far I figured to ask you guys for some insight on the matter.
有什么建議可以嘗試嗎?我正在運行 PHP 5.3.8,并且服務器的 IP 地址在遠程方的防火墻中被列入白名單.
Any suggestions what can be tried? I'm running PHP 5.3.8 and the server's IP-address is white listed in the firewall at the remote party.
推薦答案
我已經解決了這個問題.我認為,由于有關此問題的問題數量和不同解決方案的數量,其他人將從該解決方案中受益.這是:
I've fixed this problem. I think, due to the number of questions regarding this issue and number of different solutions, others will benefit from the solution. Here goes:
我使用 openssl
CLI 程序將 .p12 密鑰文件轉換為 .pem 密鑰文件.訣竅在于轉換發生的方式.
I used the openssl
CLI program to convert the .p12 key-file to a .pem key-file. The trick is the way the conversion takes place.
首先我用這個命令轉換它,我遇到了問題中描述的問題:
First I converted it with this command and I had the issue as described in the question:
openssl pkcs12 -in key.p12 -out key.pem -nodes -clcerts
雖然下面的命令做了實際的技巧:
While the command below did the actual trick:
openssl pkcs12 -in key.p12 -out key.pem -clcerts
有關更多信息,請參閱我使用的來源:https://community.qualys.com/文檔/DOC-3273
For more info please see the source I used: https://community.qualys.com/docs/DOC-3273
這篇關于帶有 SSL 證書的 PHP SOAP 客戶端的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!