Last active
November 14, 2018 12:14
-
-
Save tekbird/4556302f7d03b98c781c0e31be501b6c to your computer and use it in GitHub Desktop.
java ssl socket server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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