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() );