I received two certificate files from the provider, one in .cer format and one in .p7b format. Then I converted the p7b certificate to a p12 certificate. With this certificate, I can connect to wsdl from my browser. Then I started to convert this certificate to .pem-format, using some instructions that I found on this site.
openssl pkcs12 -clcerts -nokeys -out test.pem -in mycert.p12 openssl pkcs12 -nocerts -out key.pem -in mycert.p12
then combing cert with the key using the following command:
cat test.pem key.pem > cert.pem
Here is my design for the web service class:
public function __construct() { $wsdl_url = 'https://url.to/web_service?wsdl'; $pass = 'passphrase'; $cert = 'cert.pem'; try { $this->client = new SoapClient($wsdl_url, array('local_cert' => $cert, 'passphrase' => $pass)); } catch(SoapFault $e) { print_r($e); } }
And here is the error:
SSL operation failed with code 1. OpenSSL Error messages: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca in /var/www/html/..
Attempting to verify a certificate with:
openssl verify cert.pem
gives the following error:
error 20 at 0 depth lookup:unable to get local issuer certificate
I also tried creating a .pem certificate using the following openssl command:
openssl pkcs12 -in mycert.p12 -out mycert.pem
Checking this gives me OK, but PHP gives me the following error:
Unable to set local cert chain file `mycert.pem'; Check that your cafile/capath settings include details of your certificate and its issuer
I suppose it should be possible to make it work somehow, since I can access wsdl through my browser using a .p12 certificate. But I canβt find a solution on how I should act. Thanks in advance.