We're getting close to finalizing our secure socket setup, so stay with me!
The next step is to create an SSLContext. An
SSLContext contains all the
key and certificate information we've mentioned so far, and is used
to create an SSLSocketFactory, which in turn creates
secure sockets.
Once you've created an SSLContext at the start of an
application, you can use it for each connection you need to make, as long
as each connection uses the same keys.
To create an SSLContext, we use our factories and the
SecureRandom, as shown here:
sslContext = SSLContext.getInstance( "TLS" );
sslContext.init( kmf.getKeyManagers(),
tmf.getTrustManagers(),
secureRandom );
Note that we've created an SSLContext of type
"TLS". As you suspect, this stands for Transport Layer Security, which is the new
name for the Secure Sockets Layer, or SSL. We then initialize it with the
TrustManagerFactory and KeyManagerFactory objects
we created a few steps back.