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 experienced with php SoapClient, but I never needed to work with secure soap client.

Thanks for any help

share|improve this question

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...?

share|improve this answer
    
Thanks a lot. Of course, I tried to use it before, but I never succeed, probably becouse of relative path. – Michal Drozd Jul 27 '10 at 17:20
    
So I need make pem file from crt, dont ? I found this way: openssl x509 -in input.crt -out input.der -outform DER then openssl x509 -in input.der -inform DER -out output.pem -outform PEM – Michal Drozd Jul 27 '10 at 17:21
1  
I started getting new (catched) exception: Could not connect to host No idea what this really means. Is there any way to get more info? – Michal Drozd Jul 27 '10 at 17:31
    
Is there anything more in the exception object itself? Do you have OpenSSL compiled in (I'm assuming you do, if you got this far)? Is there anything in your server error log (or are warnings/errors on)? Nothing quite useful I can add here, apart from the usual pain-staking debug process, I'm afraid. – kander Jul 27 '10 at 17:34
    
Note sure about the PEM / CRT question; the webservice supplier gave me the PEM so that's what I rolled with. They offered example code (which the above is based on), and things pretty much 'just worked', apart from the relative path issue. – kander Jul 27 '10 at 17:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.