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
  


Setting up factories page 8 of 11


The next step is to use the KeyStore objects we've created to initialize key and trust manager factories. We'll create a TrustManagerFactory from the server keystore; this will be used to authenticate (that is, begin to trust) the remote server:


      TrustManagerFactory tmf = TrustManagerFactory.getInstance( "SunX509" );
      tmf.init( serverKeyStore );

Note that the TrustManagerFactory is of type "SunX509"; 509 is the name of the certification protocol we're using throughout this program. In the second code line, the TrustManagerFactory is loaded with the server's keystore.

We must also create a KeyManagerFactory from the client's KeyStore, as shown below:


      KeyManagerFactory kmf = KeyManagerFactory.getInstance( "SunX509" );
      kmf.init( clientKeyStore, passphrase.toCharArray() );

Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact