SSL Socket Communication Test

This section describes how to perform a SSL socket communication test with a SSL server socket test program, a SSL client socket test program, a pair of private key and public key, and a self-sign certificate of the public key.

In the previous chapter, I learned how the SSL (Secure Socket Layer) protocol works to add a layer of security protection on an Internet network communication link. In this chapter, I want to see how to apply the SSL protocol to a simple socket communication test.

In order to test SSL socket communication, I need to prepare:

1. On server machine, create a pair of private key and public key and self-sign the public key into a certificate. All this can be done using the "keytool" command and save the key pair and the certificate in a "keystore" file. See the "keytool" chapter for more information. Export the certificate of the self-signed public key to the client machine.

2. On client machine, import the certificate received from the server machine into a "keystore" file.

3. On server machine, write a SSL server socket test program and run it to listen to incoming SSL socket connection requests. The server test program must use the "keystore" created in step 1.

4. On client machine, write a SSL client socket test program and run it to connect to the server machine. The client test program must be launched with the "keystore" file created in step 2 as a "trustStore". This is needed, because the server's public key is self-signed, and not trusted by default.

See next sections for details of the SSL socket communication test.

Last update: 2014.

Table of Contents

 About This JDK Tutorial Book

 Downloading and Installing JDK 1.8.0 on Windows

 Downloading and Installing JDK 1.7.0 on Windows

 Downloading and Installing JDK 1.6.2 on Windows

 Java Date-Time API

 Date, Time and Calendar Classes

 Date and Time Object and String Conversion

 Number Object and Numeric String Conversion

 Locales, Localization Methods and Resource Bundles

 Calling and Importing Classes Defined in Unnamed Packages

 HashSet, Vector, HashMap and Collection Classes

 Character Set Encoding Classes and Methods

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Socket Network Communication

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

 SAX (Simple API for XML)

 DTD (Document Type Definition) - XML Validation

 XSD (XML Schema Definition) - XML Validation

 XSL (Extensible Stylesheet Language)

 Message Digest Algorithm Implementations in JDK

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Digital Signature Algorithm and Sample Program

 "keytool" Commands and "keystore" Files

 KeyStore and Certificate Classes

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 The SSL (Secure Socket Layer) Protocol

SSL Socket Communication Testing Programs

SSL Socket Communication Test

 SslReverseEchoer.java - SSL Server Socket Example

 SslSocketClient.java - SSL Client Socket Example

 Making Self-Signed Certificates Trusted

 javax.net.debug - Debugging SSL Socket Communication

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 Outdated Tutorials

 References

 PDF Printing Version