z/OS Cryptographic Services System SSL Programming
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Sample C++ SSL files

z/OS Cryptographic Services System SSL Programming
SC14-7495-00

A sample set of files is shipped to provide an example of what is needed to build a C++ System SSL application. These files build one DLL (SECURES) and three programs: client, server, and display_certificate. These sample files are in /usr/lpp/gskssl/examples:

  • Makefile
  • client.cpp
  • server.cpp
  • common.hpp
  • common.cpp
  • secures.h
  • secures.cpp
  • utils.hpp
  • utils.cpp
  • display_certificate.c
Note: Reference the sample source for SSL environment and connection attributes. File name and password attributes are hard-coded in the kdb file.

server (source file: server.cpp) is a multithreaded program that opens a socket on IP address 127.0.0.1, port 4321 and listens for client requests. server can run in either secure (using SSL) mode or nonsecure (using normal socket reads and writes) mode. By default, server runs with one socket listen thread and 20 work threads. The socket listen thread listens for connections from clients and puts each request onto the work list. The work threads check the work list for work and then perform the work. The number of work threads can be specified using the -numthreads parameter when starting server.

To get information about the parameters accepted when invoking the server program, issue server -?

client (source file: client.cpp) is a single threaded program that connects to the server program and exchanges one or more data packets. client can also run in secure or nonsecure mode, but its mode must match the mode of the server to which it is connecting. The number of connections, the number of read/write packets per connection, the number of bytes in each write packet, and the number of bytes in each read packet can be specified. Multiple clients can be run simultaneously to the same server.

To get information about the parameters accepted when invoking the client program, issue client -?

display_certificate (source file: display_certificate.c) is a program that can display an X.509 certificate stored in a file. The display_certificate program is only supported as a 31-bit application.

The files included in the examples are:

Makefile
This file builds the example programs and DLLs. The resulting executable DLLs are client, server and display_certificate.
To build the examples as a 31-bit application (default), issue:
/bin/make 
To build the client and server examples as a 64-bit application, issue:
/bin/make AMODE=64
Remove all compiled .o and .x artifacts, issue:
/bin/make clean
Remove all compiled .o, .x and DLL artifacts, issue:
/bin/make clobber
client.cpp
This file contains the routines that implement the client function.
server.cpp
This file contains the routines that implement the server function.
common.hpp
This contains the prototypes and defines for the routines in common.cpp.
common.cpp
This file contains a set of routines called by client and server to set up, accept, open, and close connections, and to read and write data. All data that is read or written in the form of packets that contain a header containing a command, length, and cookie. This implements a higher level communication protocol used between the client and server programs. For example, this higher level protocol allows the client to send a "STOP" request to the server, which stops the server program.
secures.h
This file contains prototypes and defines for the routines in secures.cpp.
secures.cpp
This file implements a set of APIs that are similar to the normal sockets APIs, except that the routines work in either secure (SSL) or nonsecure mode. These routines are called by code in client.cpp, server.cpp, and common.cpp.
utils.hpp
This file contains the prototype for the routine in utils.cpp, some structure definitions, and several defined constants.
utils.cpp
This file contains routines that server and client programs use to check command line options.
display_certificate.c
This file is a sample program to decode and display an X.509 certificate.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014