Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Java : Education - Tutorials
Using JSSE for secure socket communication
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
5. Using JSSE sockets
  


Creating an SSLContext page 9 of 11


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.


Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact