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.