private static class SelfSignedSSLEngineFactory implements SSLEngineFactory {
private final SslContext sslCtx;
private SelfSignedSSLEngineFactory() {
SelfSignedCertificate ssc;
try {
ssc = new SelfSignedCertificate();
} catch (CertificateException e) {
throw new IllegalStateException("Self signed certificate creation error", e);
}
try {
sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
} catch (SSLException e) {
throw new IllegalStateException("Failed to create Netty's Ssl context with self signed certificate", e);
}
}