private SslContext getSslContext() { SslContext sslCtx; if (useSsl) { SelfSignedCertificate ssc; try { ssc = new SelfSignedCertificate(host); sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey()); } catch (CertificateException | SSLException e) { e.printStackTrace(); sslCtx = null; } } else { sslCtx = null; } return sslCtx; }