带有 SSL 证书的 PHP SOAP 客户端

PHP SOAP client with certificates over SSL(带有 SSL 证书的 PHP SOAP 客户端)
本文介绍了带有 SSL 证书的 PHP SOAP 客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试使用以下代码设置 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 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)