How to create JKS keystore file on secure domain for java netty-socketIO

2.6k Views Asked by At

I need to create a JKS keystore file on a secure domain (eg: https://example.com).

I am going to use this keystore file in my java netty-socketIO server side.

 Configuration config = new Configuration();
 config.setHostname("example.com");
 config.setPort(3037);
 config.setKeyStorePassword("password");
 InputStream stream = new FileInputStream("C:/keystore.jks");
 config.setKeyStore(stream);

I am not so sure what is the best way to create the jks file and what is needed for this one.

I am using windows vps for this java socket program.

Thanks in advance

1

There are 1 best solutions below

4
On

You can use java's keytool tool. You should have java installed and the JDK bin folder in your PATH (if not run it from the JDK's bin directory).

$ keytool -keystore mykeystore.jks -genkey -alias myalias

Answer the questions with the values you want to store to your first key (myalias) and the tool will create a keystore including a key with alias myalias.

When done you can list the keys of the keystore with

$ keytool -keystore mykeystore.jks -list