Using VeriSign’s Digital ID to send SOAP messages over HTTPS
Summary
Many applications, such as Ericsson Messaging Alerts, use SOAP (Simple Object Access Protocol), a standard communication protocol, to exchange data via the internet.
In some cases, the data getting exchanged needs to be manipulated and sent towards some third party, which will produce invoice statements sent to users.
In order to avoid eavesdropping on this private information, a security layer can be added, by encrypting the SOAP messages before sending them out. This document discusses how to use a VeriSign digital ID to securely send SOAP messages over HTTPS.
Introduction
Overview
More and more applications are using SOAP as a standard way of communicating and sending messages over the internet. Indeed, this idea of Webservices is invading the IT world and introducing many security threats. The problem resides in the fact that SOAP messages are usually transferred in plain text over the network, so anyone with a sniffer can easily intercept the SOAP message and read it.
A solution to this security breach is to use HTTPS instead of HTTP. The extra ‘S’ stands for SSL, or Secure Socket Layer. Using this protocol ensures that the communication between two clients is encrypted. In order to accomplish this, a certificate needs to be obtained from a Certified Authority, such as VeriSign. This certificate is composed of two parts; the private and the public. The private component of the certificate is used to encrypt the SOAP message, and the public component is used to decrypt the message.
Secure SOAP for Billing
Many mobile applications, such as Ericsson Ring Back Tone and Ericsson MMS Alerts, are now using SOAP to generate billing information that will be sent to the users. In order to achieve this, these SOAP messages need to be manipulated and distributed, possibly to some external third party, which produces the invoice statements for the operators’ users. These SOAP messages can contain important information such as account ID, credit card information, purchase details, and so on. As discussed above, we can avoid any eavesdropping by encrypting the data before sending it out. This is outlined clearly in Figure 1 – SOAP Encryption over the Internet, below.
The basic high level idea is shown above, in which a simple XML SOAP message is first encrypted using a private key, sent over the internet to its destination, and then decrypted using the public key. In the rest of this document, I will discuss how this can be achieved.
Figure 1 – SOAP Encryption over the Internet
January 25, 2006 3 SOAP over HTTPS
Implementation Requirements
The sample code that I will be providing this document was implemented using the following specifications.
• Apache Axis 1.2.1 used for sending the SOAP messages;
• Sun’s SSL provider for Java Security, which can be used for generating key stores;
• JWSDP1 used to import .pfx files into key stores;
• VeriSign Digital ID, which will be a public/private key used in the communication.
As well, it is required to have a target URL which will be expecting to receive SOAP messages (usually through port 443) through a system call. In my case, the code was obtained for the target third party, which contained the java code I could use to invoke the service. A WSDL was provided by the third party, which I turned into java code using the WSDL2Java functionality in the Axis API.
Abbreviations
The following abbreviations are used throughout the document.
• SOAP Simple Object Access Protocol
• HTTP Hyper Text Transfer Protocol
• HTTPS Hyper Text Transfer Protocol with SSL
• SSL Secure Socket Layer
• WSDL Web Service Definition Language
• XML EXtensible Markup Language
• JWSDP Java Web Services Developer Pack
• PFX Personal InFormation Exchange
• CER Certificate
• URL Uniform Resource Locator
• PKCS Public Key Cryptographic Standard
1 Visit http://java.sun.com/webservices/downloads/webservicespack.html to obtain the latest version.
January 25, 2006 4 SOAP over HTTPS
Implementing SOAP over HTTPS
In order to implement SOAP over HTTPS, I will first discuss how to obtain a digital ID (or certificate) from VeriSign, which will be used on both the client and server side. I will focus more on the client side, since it is there where the soap message needs to be encrypted and sent. I will also discuss how the certificate is installed on the client server, in order to generate a keystore. I will then describe what Java code needs to be added to incorporate the keystore in the process of sending the SOAP message over the internet.
Therefore, these are the main steps that need to be done in order to achieve SOAP over HTTPS. They are discussed in the rest of this chapter.
1. Obtain digital ID from Certified Authority (VeriSign in this case)
2. Extract and send public component to the server.
3. Extract and install private component on the client.
4. Generate a keystore on the client machine, and import the private component into it.
5. Modify the java code that sends the soap message to initialize SSL.
Obtaining a Certificate
This section describes how to obtain a client certificate. In this document, a certificate will be obtained from VeriSign. Their certificates will be good for one year before they expire.
To obtain a certificate,
1. Go to the VeriSign website at the following location
http://www.verisign.com/products-services/security-services/pki/pki-application/email-digital-id/index.html
2. Click on the ‘Buy Now’ button.
Figure 2 – VeriSign Certificate Web Page
January 25, 2006 5 SOAP over HTTPS
3. Select Microsoft Internet Explorer to continue.
4. After proceeding, you will be presented with a four page enrollment form, in which you need to provide billing and address information, as well as some specifics concerning your certificate. These values should be confirmed with the server to whom the SOAP messages will be set. The values used for the sample are:
๔ Test drive 60 day free trial Digital ID;
๔ Cryptographic Service = Microsoft Enhanced Cryptographic Provider 1.0;
๔ Check the box to protect your key.
5. At the bottom of the form is the VeriSign is the user agreement. Click Accept to continue, and then click yes for the "Potential Scripting Violation" popup.
6. You will be presented with the following screen. Click OK to finish.
7. You will receive an e-mail from VeriSign explaining how to complete the process and receive your Certificate.
Figure 3 - VeriSign Check E-mail
January 25, 2006 6 SOAP over HTTPS
Installing the Certificate to a Browser
After verifying your mail, you will be directed to a URL in order to finalize the installation.
1. Following the link provided in your mail, and you will be presented with a screen in which you will need to enter a pin. Enter the pin from your mail.
2. You are now at the final step. Click on the "Install" button to complete the installation of the certificate in to your browser.
Extracting the Certificate
Once the certificate has been installed, it must then be extracted into two components, public and private. We will first see how to extract the public key, which will be sent to the server side, and then we will extract the private key, which will be used on the client side to encrypt the SOAP message.
Public Key Extraction
After downloading the certificate to your browser, you can now extract the public component and save it as a certificate file (.cer). This file will then need to be set up on the target secure web server, which will be receiving the SOAP messages from the client.
To extract the key,
1. Open your IE browser and select "Internet Options" from the "Tools" menu.
2. If you click on the "Content" tab, you will have the following window.
Figure 4 - IE Options
January 25, 2006 7 SOAP over HTTPS
3. Click on the "Certificates" to continue and view your certificates. You will be presented with the following window.
4. Click on the "Personal" tab and then select the certificate you just obtained.
5. Click on the "Export…" button.
6. A new window will appear. Click on "Next".
7. Select "No, do not export the private key".
8. Select the "Base-64 encoded X.509 (.CER)" format.
9. Click on the "Browse" button to select a destination, and then enter a filename for your public component of the certificate.
10. You will get a final window with the summary of the extraction. Click on "Finish".
You know have the public component of the VeriSign Digital ID. If not already done, it should be forwarded to the server that will be receiving the SOAP encrypted messages. Next we will see how to extract the private component.
Private Key Extraction
The next step is to extract the private key, which will be then imported into a keystore, and then configured to encrypt outgoing SOAP messages.
Figure 5 - IE Certificates Panel
January 25, 2006 8 SOAP over HTTPS
To export the private key,
1. Follow steps 1-7 from the "Public Key Extraction" section.
2. Select "Yes, export the private key" option and continue.
3. Select the "Personal Information Exchange – PKCS 12" format, and check the "Enable strong protection" checkbox. Click on "Next".
4. Specify and confirm a password, and click on "Next".
5. Click on the "Browse" button to select a destination, and then enter a filename for the private component of your certificate.
6. You will get a final window with the summary of the extraction. Click on "Finish".
Installing the Private Key
Now that the private key is obtained, the next step is to create a keystore, and import the private key into it. Once that is set up, all that is left to do is to have a reference to that keystore in the java code, before invoking the final service on the server.
Figure 6 - Creating the KeyStore
#> keytool -genkey -alias mykey -keyalg RSA -keystore /home/keystore.ks
Enter keystore password: ericsson
What is your first and last name?
[Unknown]: Mohannad Zikra
What is the name of your organizational unit?
[Unknown]: SI
What is the name of your organization?
[Unknown]: Ericsson
What is the name of your City or Locality?
[Unknown]: Montreal
What is the name of your State or Province?
[Unknown]: Quebec
What is the two-letter country code for this unit?
[Unknown]: CA
Is CN=Mohannad Zikra, OU=SI, O=Ericsson, L=Montreal, ST=Quebec, C=CA correct?
[no]: yes
Enter key password for
(RETURN if same as keystore password):
January 25, 2006 9 SOAP over HTTPS
Once that is done, a keystore file would be creating in the home directory, names "keystore.ks". The next step that is described below is to import the private key component into this keystore.
The
Once this is completed, we now have the keystore with the private key imported into it, as well as the keystore password. The next and final step is to reference this keystore from the java code.
Using KeyStore in Java Application
The final step is to set up our java code to make use of all this keystore that we just created. This needs to be done at anytime before invoking the service that requires sending SOAP over HTTPS. In the code below, I show a function, called "initSSL()" which performs this setup. Calling this function before invoking the SOAP call will ensure that the transmission be encrypted with the private key in the keystore.
#> jwsdp-1.6/xws-security/bin/pkcs12import.sh -file
Figure 7 - Importing Private Key
Figure 8 - initSSL() Function
January 25, 2006 10 SOAP over HTTPS
Troubleshooting
In case your application does not succeed at the first shot, try running it with the debugging options below. These commands are very helpful and will allow you to see exactly how your keystore is being used, what is being sent, and how the server is responding to the SOAP request.
In order to get a whole bunch of SSL debugging messages, include these options while executing your application.
-Djavax.net.debug=ssl,handshake,data,trustmanager
January 25, 2006 11 SOAP over HTTPS
Last Words
This document was inspired by the hard work that was placed in the development of Billica, an Ericsson billing solution that uses SOAP as a communication protocol to manipulate billing information for Ring Back Tone and MMS Alerts purchases.
Hopefully this guide will assist you in succeeding to send SOAP messages over HTTPS. If you have any comments, or if you find any mistakes in this document, please do not hesitate to share them. I will gladly make the necessary modifications!
If you would like to get some more information on the Billica solution or on general SOAP over HTTPS, please do not hesitate to contact me.
Contact Information
I can be reached via email, at Mohannad.Zikra@ericsson.com.
January 25, 2006 12
No comments:
Post a Comment