Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Secure Communication Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

7.1 Getting Started with HTTPS

The following examples show how to retrieve documents using HTTPS.


NOTE -- This chapter describes only new information about the use of HTTP over a secure channel. It assumes that you understand the HTTP package (Rogue Wave Internet Protocols Module) and the Secure Sockets package.

7.1.1 Using RWHttpAgent to Retrieve a Document Securely

This example uses the HTTP agent class on https:// URIs. An agent class uses its respective client class to perform common protocol requests.

This example uses utility functions provided in util.h.

Example 10: Using a Secure Agent

//1Initialize Windows Sockets (does nothing on UNIX).
//2Initialize the Secure Sockets package.
//3Seed the Random Number Generator in the Secure Sockets package. (Note: Seeding the random number generator from a const string is not secure and not recommended in production applications, but is sufficient for this example.)
//4Create a RWSecureSocketContext instance.
//5Initialize the context. This call instructs the context to prepare to authenticate the server we will connect to. The TRUSTED_CERTS_FILE is a text file that contains the root certificates of the certificate authorities we trust. (For simplicity, we do not perform authentication in this example.)
//6Instruct the HTTPS package to use this context whenever we use an agent on an "https://" URI.
//7Create an agent.
//8Create the URL of the resource we want to get.
//9Create an IOU to store the result.
//10Instruct the agent to use the HTTP GET method on the URL supplied.
//11Redeem the IOU to get the reply from the agent. This call may block until the agent fully acquires the result.
//12If the GET request was successful, display the body of the document on the screen.

7.1.2 Using RWHttpsSecureSocketClient to Retrieve a Document

This example uses the HTTPS client class. A client class allows low-level access to and encapsulates the details of the protocol.

This example uses utility functions provided in util.h.

Example 11: Using a Secure Client

//1Initialize Windows Sockets (does nothing on UNIX).
//2Initialize the Secure Sockets package.
//3Seed the Random Number Generator in the Secure Sockets package (Note: Seedin the random number generator from a const string is not secure and not recommended in production applications, but is sufficient for this example).
//4Create a RWSecureSocketContext instance.
//5Initialize the context. This call instructs the context to prepare to authenticate the server we will connect to. The <certificate_file> is a text file that contains the root certificates of the certificate authorities we trust. (For example, we do not perform authentication in this example.)
//6Create a HTTP client handle.
//7Create an RWHttpsSecureSocketClient and associate the context with it. Connect this body with the handle created in //6.
//8Create a request for the root document.
//9Connect the client to the host and submit the request created in //8.
//10Get the reply from the server. This function blocks until a reply is available.
//11If the request was successful, write the body of the document to standard output.


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.