I am currently working on a university little project in which we should make an android application which can communicate with a java SSL Socket. I am kinda new on the SSL connections, I red about keystores and stuff but I didn't really get it.
This is the Android side:
SSLSocketFactory socketFactory;
SSLSocket socket;
socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
try {
socket = (SSLSocket) socketFactory.createSocket("192.168.1.131", 7070);
System.out.println("Connected!");
} catch (IOException e) {
e.printStackTrace();
}
This is the java server one:
SSLServerSocketFactory socketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
SSLServerSocket serverSocket = (SSLServerSocket) socketFactory.createServerSocket(7070);
serverSocket.setEnabledProtocols(new String[] {"TLSv1.3"});
while (true) {
// wait for client connection and check login information
try {
System.err.println("Waiting for connection...");
SSLSocket socket = (SSLSocket) serverSocket.accept();
System.out.println("Connessione Accettata");
// open BufferedReader for reading data from client
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// open PrintWriter for writing data to client
System.out.println(input);
//PrintWriter output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
//output.close();
input.close();
socket.close();
} // end try
// handle exception communicating with client
catch (IOException ioException) {
ioException.printStackTrace();
}
}
Obviously the sockets don't even connect each other, what should I implement to make it work?