Netty SocketIO如何支持客户端的SSL访问还是比较简单的,大体上分两个步骤:
1)准备JKS密钥库;
keytool -genkey -alias websocket -keyalg RSA -keysize 4096 -keypass 123456 -keystore C:\keystore.jks -storepass 123456 -dname "cn=websocket,ou=mydept,o=mycompany,l=sh,st=sh,c=cn" -ext san=ip:10.10.10.10 -validity 3650 -storetype JKS
2)SocketIOServer启动配置Configuration增加两个设置:keyStorePassword和keyStore。
Configuration config = new Configuration();
config.setHostname("10.10.10.10");
config.setPort(8092);
log.info("hostAddress: {}, port: {}", hostAddress, port);
config.setKeyStorePassword("123456");
String keyStoreLocation = "C:/keystore.jks";
InputStream stream = null;
try {
stream = new FileInputStream(keyStoreLocation);
} catch (Exception e) {
log.error("Error in loading jks file from: {}", keyStoreLocation);
e.printStackTrace();
return null;
}
config.setKeyStore(stream);
return new SocketIOServer(config);