I'm unable to make an encrypted SOAP request in PHP. As per the documentation, I encrypted each request to the payment gateway. I generated a CSR & sent it to the authority for the certificate. They sent back me the domain certificate & CA certificate. The biggest problem is that the documentation is not meant for PHP. As per the document:
The web service is protected with WS-Security Sign and encryption policy
After searching a long time I found a helper class from Git but whenever I try to connect I get the following error:
General security error (No certificates were found for decryption (KeyId))
FaultCode : wsse:InvalidSecurity
I tried to set SSL header as follows:
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'cafile' => '../../certs/CA.cer',
'local_cert' => '../../certs/server.cer',
'local_pk' => '../../certs/private_key.key',
'verify_depth' => 0,
'allow_self_signed'=>true,
)
);
$sslContext = stream_context_create($contextOptions);
Update
I defined the keys as :
define('PRIVATE_KEY', 'server_prvate_key.key');
define('CERT_FILE', 'domain_cert.cer');
define('SERVICE_CERT', 'CA.cer');
Anything wrong with this definition (please see the above GIT link)?
Are you tried using curl?
Use the following option to set your certificate:
curl_setopt($ch,CURLOPT_CAINFO, 'CA.cer' );
curl_setopt($ch,CURLOPT_SSLCERT, 'domain_cert.cer' );
curl_setopt($ch,CURLOPT_SSLKEY, 'server_prvate_key.key' );
curl_setopt($ch,CURLOPT_SSLCERTPASSWD, 'certificate_password' ); //if have
I use encrypted connection to payment gateways and other services using curl and works like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With