Securing Web Services with X.509 Certificates (Page 1 of 4 ) Last week's exercise began teaching you about the security and policy enhancements for Web Services 2.0. This article, covering the second exercise in the lab, picks up where last week's left off. It was written by MSDN Virtual Labs. Exercise 2 Securing Web Services with X.509 Certificates Scenario In the last exercise you were able to secure SecureInvoiceServiceA by requiring UsernameToken authentication, a message signature, and encryption. Using UsernameToken for signing and encrypting messages is not the most secure option. Using a binary security token, such as an X.509 certificate, offers a higher level of security. In this exercise, you'll walk through the process of installing some sample certificates and configuring your application to use them for signature and encryption purposes. You'll be working in the Exercises\B\before directory. Tasks Detailed steps Installing the Sample Certificates WSE 2.0 provides two sample certificates for you to use while testing your WSE 2.0 applications. These two certificates were generated by the makecert tool provided in the Microsoft Platform Software Development Kit. In order to begin using these certificates in your applications, you must first install them on your computer.
Note: you should not use these sample certificates in a production environment. You must contact a certificate authority, request your own certificate, and follow the procedures shown here to use it.
- Open an MMC console by pressing Start, press Run, type mmc, and then click OK.
- On the File menu, click Add/Remove Snap-in
- Click Add, under Snap-in, double-click Certificates.
- Click My user account to add the certificates for the current user. Click Finish.
- Click Add, under Snap-in, double-click Certificates.
- Click Computer account for the local machines certificates.
- Click Next.
- Click Finish.
- Click Close.
- Click OK.
- Your MMC window should now look something like this:
- In the console tree, click Certificates - Current User | Personal.
- Open the Certificate Import wizard by clicking Action | All Tasks | Import….
- Click Next.
- In the File Name field, type C:\Program Files\Microsoft WSE\v2.0\Samples\Sample Test Certificates\Client Private.pfx.
- Click Next.
- In the Password field, type wse2qs.
- Click Next.
- Click Next.
- Click Finish.
- Click OK.
Note: this certificate will be used by our client application to sign messages sent to the service. It could also be used to identify the client for authentication purposes.
- In the console tree, click Certificates (Local Computer) | Personal.
- Open the Certificate Import wizard by clicking Action | All Tasks | Import….
- Click Next.
- In the File Name field, type C:\Program Files\Microsoft WSE\v2.0\Samples\Sample Test Certificates\Server Private.pfx.
- Click Next.
- In the Password field, type wse2qs.
- Click Next.
- Click Next.
- Click Finish.
- Click OK.
Note: this certificate will be used to encrypt messages between the applications. The client application will use the public key to encrypt the message and the service will use the private key to decrypt the message. The client needs to have the public portion of the certificate available in the Current User store.
- In the console tree, click Certificates - Current User | Other People.
Note: if you don't have an Other People store under Current User, open Internet Explorer, click Tools | Internet Options | Content, and click the Certificates button. Click the Other People tab in the certificates dialog. You can import the certificate by clicking Import….and then following steps hh-mm.
- If importing in the mmc, open the Certificate Import wizard by clicking Action | All Tasks | Import….
- Click Next.
- In the File Name field, type C:\Program Files\Microsoft WSE\v2.0\Samples\Sample Test Certificates\Server Public.cer.
- Click Next.
- Click Next.
- Click Finish.
- Click OK.
- If importing through Internet Explorer, click Close, click OK, close Internet Explorer, and return to the mmc.
- Close the mmc.
- If prompted to save settings, click No.
Note: this certificate only contains the public portion of Server Private.pfx. The client will use this to encrypt messages and the server will use the private key installed in the Local Machine store to decrypt the messages.
Next: Signing with a Certificate >>
More Visual Basic.NET Articles More By MSDN Virtual Labs |