Axis2/C has strong support for message level web services security. It also provides wire level protection between web services and its clients. In this guide I do not detail basics of Axis2/C web services. You can refer for them else where. WSO2 Oxygen Tank is a good place for you to refer. Here are the steps.
1. Make sure your Apache2 web server is installed with mod_ssl module support.
2. Configure and install Axis2/C with ssl support
3. Configure your Apache2 server with ssl support
4. Configure your clients to access secured web service.
Following are the steps in detail
1. Install Apache2 with ssl support:
Make sure that your Apache2 server is installed with mod_ssl support. Here is how to check your installed modules.
httpd -l
If your Apache2 server does not already have mod_ssl module support you may need to configure it again and install.
Here is an example configuration.
%./configure --prefix=/usr/local/apache2 --enable-ssl --enable-setenvif --enable-mods-shared="mod_log_config mod_status mod-mime mod-dir"
2. Configure and install Axis2/C with SSL support:
First you need to install openssl dev package. In Ubuntu and Dabian related distros you can install it by
%sudo apt-get install libssl-dev
%sh configure --prefix=${AXIS2C_HOME} --enable-openssl=yes --with-apache2=/usr/local/apache2/include
%make
%make install
3. Configure Apache2 server for ssl support:
You need to create certificates for your server. Here I just show you the command how
to create a self signed certificate for testing purposes. A detailed explanation on
creating your certificates with certificate authorities please refer to
http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#selfcert
%openssl req -new -x509 -nodes -out server.crt -keyout server.key
In httpd.conf Add the virtual host entry for https server as following
Note that you need to replace ‘localhost’ with your running server name
and replace the paths with the paths to above generated key/certificates.
<VirtualHost localhost:443>
DocumentRoot “/usr/local/apache2/htdocs”
SSLEngine on
SSLCertificateFile /usr/local/apache2/damitha-cert/server.crt
SSLCertificateKeyFile /usr/local/apache2/damitha-cert/server.key
</VirtualHost>
You can test your ssl enabled server with the following command
%openssl s_client -connect localhost:443
4. Configure your Axis2/C client to support ssl
Create the client certificates to access your secured web service as following
%echo |\
openssl s_client -connect localhost:443 2>&1 |\
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > client_cert.pem
Remember to replace the ‘localhost’ in the above command with your secured
server url
Now to send ssl secured messages using your Axis2/C client uncomment the
following https related entries in axis2.xml
<transportReceiver name=”https”>
<parameter name=”port” locked=”false”>6060</parameter>
<parameter name=”exposeHeaders” locked=”true”>false</parameter>
</transportReceiver>
<transportSender name=”https”>
<parameter name=”PROTOCOL” locked=”false”>HTTP/1.1</parameter>
</transportSender>
<parameter name="SERVER_CERT">/path/to/ca/certificate</parameter>
Remember to replace the server certicate path with the path to the client certificate created above.
Now you are good to go with your secured Axis2/C web services.