简体   繁体   English

PHP使用客户端证书调用Soap函数

[英]php calling soap function using client certificate

I am facing an issue with calling soap function. 我在调用soap函数时遇到问题。 I am getting error "Could not connect to host". 我收到错误消息“无法连接到主机”。 I am using "wamp server", "php version 5.3.13" and "apache version 2.2.22". 我正在使用“ wamp服务器”,“ php版本5.3.13”和“ apache版本2.2.22”。

I have client certificate in .p12 format, wsdl file available at local system and i have tested soap call using soapUI-m-snapshot. 我有.p12格式的客户端证书,本地系统上有wsdl文件,我已经使用soapUI-m-snapshot测试了soap调用。 It works fine! 工作正常! But when i am trying same with php "SoapClient" getting "Could not connect to host". 但是,当我用php“ SoapClient”尝试相同时,得到“无法连接到主机”。 I am using following soap options 我正在使用以下肥皂选项

$soapclient_options = array();
$soapclient_options['cache_wsdl'] = 'WSDL_CACHE_NONE';
$soapclient_options['local_cert'] = $certificatePath;
$soapclient_options['passphrase'] = $api_certificate_passphrase;
$soapclient_options['trace'] = true;
$soapclient_options['connection_timeout'] = 15;
$soapclient_options['ssl_method'] = 'SOAP_SSL_METHOD_SSLv3';
$soapclient_options['location'] = 'api location';

$client = new SoapClient($wsdl_path, $soapclient_options);
$client->__setLocation($soapclient_options['location']);

Am i doing something in wrong way? 我做错事了吗? Someone please suggest me and many thanks in advance. 有人请建议我,非常感谢。

PHP Soap client accepts only pem certificates. PHP Soap客户端仅接受pem证书。 You can covert your certificate using: 您可以使用以下方法隐藏证书:

openssl pkcs12 -in in.p12 -out out.pem -nodes -clcerts

Additional code needed to make it work with PHP 5.6 version. 使它与PHP 5.6版本兼容需要其他代码。

$soapclient_options['stream_context'] = stream_context_create(
            array(
                'ssl' => array(
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                )
            )
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM