Michal Drozd
Michal Drozd

Reputation: 1351

How to use PHP5 SoapClient::SoapClient() with client certificate?

I need to use PHP's SoapClient with myfile-ca.crt. How can I tell SoapClient constructor to work with client certificate (crt file) ?

I am familiar with php SoapClient, but I never needed to work with secure soap client.

Thanks for any help

Upvotes: 1

Views: 16099

Answers (1)

kander
kander

Reputation: 4286

When constructing your SoapClient, you can pass in a configuration array as the second parameter. This array allows the options local_cert. The local_cert option should point to the certificate file (in my experience the absolute path was needed to get it to work).

$wsdl = "service.wsdl";
$cert = "c:\secure_cert\webservice.pem";
$client = new SoapClient($wsdl, array('local_cert' => $cert);

See also the examples at the SoapClient manual page

Note: I've always been given .pem files; not sure if .crt is the same / works the same...?

Upvotes: 4

Related Questions