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.
Pingback: Recent Links Tagged With "encrypt" - JabberTags
I was wondering if you had experience or resources with method one, more specifically, connect to a service that’s using a self-signed cert? I’m still digging and I haven’t found a solution…. Using PHP to talk to a WCF webservice (implying IIS7). =/
Try WSF/PHP community http://wso2.org/forum/188.