Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Secure Web services: Encryption

Hedley Proctor, Software engineer, EMC
Hedley Proctor is a software engineer at IBM Hursley, England. He has worked on versions 5 and 5.1 of the WebSphere SDK for Web Services, specializing in the Eclipse plugins, samples, and interoperability. He took an undergraduate degree in Physics at Oxford University and a Postgraduate Diploma in Philosophy at Durham University, before joining IBM in September 2002.

Summary:  In this tutorial, you will learn how to create secure communications between cross-platform and cross-language Web services. It shows a scenario of a .NET client that connects to a Java Web service using XML encryption. Along the way, you'll see how to create a service and configure its security certificates and how to create and configure the client. You'll also learn some of the interoperability pitfalls of working with .NET.

Date:  07 May 2004
Level:  Intermediate PDF:  A4 and Letter (652 KB | 30 pages)Get Adobe® Reader®

Activity:  5349 views
Comments:  

Introduction

What is this tutorial about?

This tutorial is about creating secure encrypted communications in a cross-platform environment. It describes the methods of creating XML encryption for an application service and then creating a secure client service that has that same encryption settings and security certificates to communicate with the service. This scenario can be implemented in any number of different permutations of open standards platforms. In Resources, you'll find other tutorials on how to create secure communications between platforms. However, if you are a .NET user, you may have to use the process described in this example. It shows one common scenario of a .NET client connecting to another waiting service running on IBM(R) WebSphere(R) Application Server. It gives not only a demonstration of interacting between application platforms but also between those written in different programming languages. This tutorial shows how to connect a .NET client to a Java Web service using XML encryption. Along the way, you will see how to create the Web service and configure it with your own security certificates. You will also see how to create and configure the clients, and what interoperability pitfalls exist when working with .NET.

In this tutorial, we will:

  1. Create a simple online bookstore Web service with WebSphere Studio Application Developer, starting from a Web Services Description Language (WSDL) document.
  2. Configure this Web service for XML encryption.
  3. Write a Visual Basic .NET client for this Web service and configure it to use the same XML encryption settings and security certificates that the Web service uses.
  4. Test this .NET client.
  5. See the slight jab with the what interoperability pitfalls exist when working with .NET.

Should I take this tutorial?

This tutorial is designed to show how to link a .NET client written in Visual Basic to a Java Web service, if you have to use .NET client platforms. You should have a basic understanding of Web services and associated technologies like Web Services Description Language (WSDL), Simple Object Access Protocol (SOAP), and who want to learn how to construct a Java Web service and a Microsoft Visual Basic .NET client that communicate with one another using XML encryption. This tutorial complements my earlier tutorial on basic authentication and XML digital signatures. (See Resources for a link.)

The development tools I used to create and run the Web service used in this tutorial were:

  • IBM WebSphere Studio Application Developer 5.1.0
  • Microsoft Visual Studio .NET 2003 with Web Services Enhancements 1.0 SP1.

Microsoft Windows 2000 and Windows XP operating systems were used to complete the work for this tutorial. You should have a basic knowledge of security certificates and how encryption works. An overview of how encryption works can be found in Encryption: A brief introduction . You should also be familiar with IBM WebSphere Application Server -- for instance, you should know how to turn its security on and off. If you would like to read the tutorial but feel unsure about any of these subjects, Resources has links to appropriate documentation.


Sample code

Before you begin working your way through the tutorial, unzip the source code archive, ws-encryptcode.zip, that is provided. There are two subdirectories in the source code folder, each containing two files.

  • The Enc_wsdl_and_Java_implementation_file directory contains:
    • bookstoreEnc.wsdl -- This is the WSDL file you will use to create the skeleton of the Web service at the start of the tutorial, in Examine the WSDL. It defines the credit card purchase service your Web service will provide.
    • CreditCardBindingImpl.java -- A Java source code file that you will use to fully implement the credit card purchase service in Create the Web service.
  • The Enc_cert_and_keystore directory contains:
    • interops-enc-receiver.jceks
    • interops-enc.cer
    The interops-enc-receiver.jceks keystore holds the private key that your Web service will need to decrypt incoming messages. You will configure the Java Web service to use it in Security certificates. interops-enc.cer is an X.509 certificate that contains the public key that the .NET client will use to encrypt its messages. You will configure the client to use it in Installing the public key security certificate.

Encryption: A brief introduction

Before we really get started, let's have a brief recap of how encryption works. The earliest form of computerized encryption used a symmetric, or secret key. All parties who wished to encrypt or decrypt data had to have access to the same key. An encryption algorithm called DES (later superceded by triple DES) became the standard. However, this system had a major weakness. The key needed to be distributed to all the parties wishing to encrypt and decrypt data. If the key were intercepted, a hostile party could decrypt the information.

In the 1970s, a huge breakthrough was achieved in cryptography with the invention of the public and private key encryption mechanism. This mechanism uses the class of mathematical functions called trapdoor functions. Two keys are used: one to encrypt the data and the other to decrypt it. If I want people to be able to send me encrypted data, I simply distribute my public encryption key. They use this key to encrypt the information, safe in the knowledge that only I possess the private key necessary for decryption. A number of different encryption algorithms, based on this approach, have been put forward, but by far the most commonly used is RSA.

Public and private key encryption is more secure than symmetric encryption, since it doesn't require key distribution. However, it is much slower to actually encrypt data using most asymmetric mechanisms -- so much so that encrypting large amounts of data asymmetrically is usually not feasible. To get the best of both worlds, a hybrid system has been developed:

  1. The sender generates a symmetric session key and encrypts data with this key.
  2. The sender encrypts the session key using the receiver's public key and attaches this encrypted key to the message.
  3. The receiver uses his or her private key to decrypt the session key, then uses that session key to decrypt the message.

Thus, we have the speed of symmetric encryption with the security of public key encryption. The session key is, as the name suggests, used only once. So, even if a hostile party somehow managed to decrypt session key, they would only be able to decrypt one message. This method is the one we will use in this tutorial, with triple DES as our symmetric algorithm and RSA as our asymmetric algorithm.

1 of 8 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=137320
TutorialTitle=Secure Web services: Encryption
publish-date=05072004
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.