1 package com.freemindcafe.socket.ssl.sample3;
4 import javax.net.ssl.SSLSocket;
5 import javax.net.ssl.SSLSocketFactory;
18 public void simple_client_connection_with_server_succeeds_as_client_and_server_keystore_has_each_others_key(){
22 "javax.net.ssl.trustStore",currentDir()+
"/src/com/freemindcafe/socket/ssl/sample3/clientkeystore.jks");
23 System.setProperty(
"javax.net.ssl.trustStorePassword",
"password");
25 "javax.net.ssl.keyStore",
26 currentDir()+
"/src/com/freemindcafe/socket/ssl/sample3/clientkeystore.jks");
27 System.setProperty(
"javax.net.ssl.keyStorePassword",
"password");
28 System.setProperty(
"javax.net.debug",
"ssl:handshake");
31 SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory
33 SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(
36 InputStream inputstream = System.in;
37 InputStreamReader inputstreamreader =
new InputStreamReader(
39 BufferedReader bufferedreader =
new BufferedReader(
42 OutputStream outputstream = sslsocket.getOutputStream();
43 OutputStreamWriter outputstreamwriter =
new OutputStreamWriter(
45 BufferedWriter bufferedwriter =
new BufferedWriter(
49 while ((
string = bufferedreader.readLine()) != null) {
50 bufferedwriter.write(
string +
'\n');
51 bufferedwriter.flush();
53 }
catch (Exception exception) {
54 exception.printStackTrace();