Closed aguel closed 7 years ago
I've been struggling with Nettosphere with java keystore JKS file or PEM/KEY files for SSL. Any sample code or code snippet? Thanks
Been trying this:
Config.Builder builder = new Config.Builder(); builder.resource(new Handler() { public void handle(AtmosphereResource r) { r.getResponse().write("Secure Hello World").closeStreamOrWriter(); }}) .sslContext(createSSLContext()) .port(8080) .host("0.0.0.0") .build();
And the createSSLContext method:
private static SSLContext createSSLContext() { try { File initialFile = new File("/Users/aguel/Personal/Development/Java/Workspace/PushServer/server.jks"); InputStream keyStoreStream = new FileInputStream(initialFile); char[] keyStorePassword = "xxx".toCharArray(); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(keyStoreStream, keyStorePassword); // Set up key manager factory to use our key store char[] certificatePassword = "xxx".toCharArray(); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory .getDefaultAlgorithm()); kmf.init(ks, certificatePassword); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(kmf.getKeyManagers(), null, null); logger.info("SSL Context"); return sslContext; } catch (Exception e) { throw new Error("Failed to initialize SSLContext", e); } }
Getting this error:
15:58:42.116 [New I/O worker #1] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.124 [New I/O worker #1] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.129 [New I/O worker #1] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0x55e794e6, /0:0:0:0:0:0:0:1:51471 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1 15:58:42.131 [New I/O worker #2] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.132 [New I/O worker #2] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.132 [New I/O worker #2] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0xeb498464, /0:0:0:0:0:0:0:1:51474 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1 15:58:42.135 [New I/O worker #3] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.136 [New I/O worker #3] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.136 [New I/O worker #3] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0x1a379bda, /0:0:0:0:0:0:0:1:51475 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1
@aguel please use the atmosphere mailing list for questions.
I've been struggling with Nettosphere with java keystore JKS file or PEM/KEY files for SSL. Any sample code or code snippet? Thanks
Been trying this:
And the createSSLContext method:
Getting this error:
15:58:42.116 [New I/O worker #1] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.124 [New I/O worker #1] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.129 [New I/O worker #1] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0x55e794e6, /0:0:0:0:0:0:0:1:51471 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1 15:58:42.131 [New I/O worker #2] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.132 [New I/O worker #2] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.132 [New I/O worker #2] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0xeb498464, /0:0:0:0:0:0:0:1:51474 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1 15:58:42.135 [New I/O worker #3] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.136 [New I/O worker #3] ERROR o.a.nettosphere.BridgeRuntime - Unexpected and unhandled I/O Exception 15:58:42.136 [New I/O worker #3] WARN o.a.nettosphere.BridgeRuntime - Invalid attachment java.lang.Error and Channel [id: 0x1a379bda, /0:0:0:0:0:0:0:1:51475 :> /0:0:0:0:0:0:0:1:8080] at 0:0:0:0:0:0:0:1