Skip to content

Instantly share code, notes, and snippets.

@tekbird tekbird/server.java
Last active Nov 14, 2018

Embed
What would you like to do?
java ssl socket server
public static void main(String[] args) throws IOException {
System.setProperty("javax.net.ssl.keyStore", "C:\\path\\to\\keystore\\store.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "Password1");
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
ServerSocket ss = ssf.createServerSocket(7000);
System.out.println("started");
while (true) {
Socket s = ss.accept();
System.out.println("connected");
InputStreamReader reader = new InputStreamReader(s.getInputStream());
char[] chars = new char[10];
reader.read(chars);
System.out.println(new String(chars));
s.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.