August 14th, 2008Encrypt and Sign your SOAP messages in PHP
When you are developing a Web Service, you have to think about the security aspects of your service seriously. When it comes to security in web services you have two basic choices.
- Transport level security – Just SOAP over HTTPS
- Message level security – WS-Security
See my previous blog comparing Transport level and Message level security.
If you are satisfied with the security provided by using just ‘SOAP over HTTPS’, you can get the work done by configuring your server (Apache or IIS) to enable ssl. See http://www.onlamp.com/pub/a/onlamp/2008/03/04/step-by-step-configuring-ssl-under-apache.html for an step by step guide for configure SSL in your Apache server.
If you want message level security for your application, just use WS-Security. With WSF/PHP it is even easier to implement than SOAP over HTTPS method, because you can provide the certificates programatically in PHP and no need to do further configuration.
WSF/PHP provides you two classes in line with WSService to implement an API to provide WS-Security.
- WSPolicy -Let you provide rules that the engine need to follow in securing the message. E.g.
$policy = new WSPolicy(array("security"=> array("encrypt" => TRUE, "algorithmSuite" => "Basic256Rsa15", "securityTokenReference" => "IssuerSerial")));
In fact you can load policies from an xml which adheres to the WS-SecurityPolicy specification.
- WSSecurityToken – Keeps the security tokens like certificates, keys, username, passwords which would be used when applying the rules specified in the policy. E.g.
$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, "receiverCertificate" => $pub_key));
You can see the WS-Security in action on live from http://labs.wso2.org/wsf/php/samples/security/ and security demo ource codes.
August 29th, 2008 at 7:01 am
[...] public links >> encrypt Encrypt and Sign your SOAP messages in PHP Saved by asvensson on Fri 29-8-2008 Encrypting your footer link Saved by RLCheerchick123 on Thu [...]