@Test public void testCreateSslContextNoKeyStorePasswordOpenSSL() throws Exception { assumeTrue(OpenSsl.isAvailable()); assumeTrue(OpenSsl.supportsKeyManagerFactory()); TransportOptions options = createJksSslOptions(); options.setKeyStorePassword(null); try { TransportSupport.createOpenSslContext(options); fail("Expected an exception to be thrown"); } catch (UnrecoverableKeyException e) { } catch (IllegalArgumentException iae) { String message = iae.getMessage(); assertTrue("Unexpected message: " + message, message.contains("password can't be null")); } }
public static SslContext createOpenSslContext(TransportOptions options) throws Exception { try { String contextProtocol = options.getContextProtocol(); LOG.trace("Getting SslContext instance using protocol: {}", contextProtocol); KeyManagerFactory keyManagerFactory = loadKeyManagerFactory(options, SslProvider.OPENSSL); TrustManagerFactory trustManagerFactory = loadTrustManagerFactory(options); SslContextBuilder builder = SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL); if (options.getContextProtocol().equals(TransportOptions.DEFAULT_CONTEXT_PROTOCOL)) { builder.protocols("TLSv1.2"); } else { builder.protocols(options.getContextProtocol()); } builder.keyManager(keyManagerFactory); builder.trustManager(trustManagerFactory); return builder.build(); } catch (Exception e) { LOG.error("Failed to create SslContext: {}", e, e); throw e; } }
TransportSupport { public static SslContext createOpenSslContext(TransportOptions options) throws Exception { try { String contextProtocol = options.getContextProtocol(); LOG.trace("Getting SslContext instance using protocol: {}", contextProtocol); KeyManagerFactory keyManagerFactory = loadKeyManagerFactory(options, SslProvider.OPENSSL); TrustManagerFactory trustManagerFactory = loadTrustManagerFactory(options); SslContextBuilder builder = SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL); if (options.getContextProtocol().equals(TransportOptions.DEFAULT_CONTEXT_PROTOCOL)) { builder.protocols("TLSv1.2"); } else { builder.protocols(options.getContextProtocol()); } builder.keyManager(keyManagerFactory); builder.trustManager(trustManagerFactory); return builder.build(); } catch (Exception e) { LOG.error("Failed to create SslContext: {}", e, e); throw e; } } }
TransportSupport { public static SslContext createOpenSslContext(TransportOptions options) throws Exception { try { String contextProtocol = options.getContextProtocol(); LOG.trace("Getting SslContext instance using protocol: {}", contextProtocol); KeyManagerFactory keyManagerFactory = loadKeyManagerFactory(options, SslProvider.OPENSSL); TrustManagerFactory trustManagerFactory = loadTrustManagerFactory(options); SslContextBuilder builder = SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL); if (options.getContextProtocol().equals(TransportOptions.DEFAULT_CONTEXT_PROTOCOL)) { builder.protocols("TLSv1.2"); } else { builder.protocols(options.getContextProtocol()); } builder.keyManager(keyManagerFactory); builder.trustManager(trustManagerFactory); return builder.build(); } catch (Exception e) { LOG.error("Failed to create SslContext: {}", e, e); throw e; } }  }
TransportSupport { public static SslContext createOpenSslContext(TransportOptions options) throws Exception { try { String contextProtocol = options.getContextProtocol(); LOG.trace("Getting SslContext instance using protocol: {}", contextProtocol); KeyManagerFactory keyManagerFactory = loadKeyManagerFactory(options, SslProvider.OPENSSL); TrustManagerFactory trustManagerFactory = loadTrustManagerFactory(options); SslContextBuilder builder = SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL); if (options.getContextProtocol().equals(TransportOptions.DEFAULT_CONTEXT_PROTOCOL)) { builder.protocols("TLSv1.2"); } else { builder.protocols(options.getContextProtocol()); } builder.keyManager(keyManagerFactory); builder.trustManager(trustManagerFactory); return builder.build(); } catch (Exception e) { LOG.error("Failed to create SslContext: {}", e, e); throw e; } }  static boolean isOpenSSLPossible(TransportOptions options); static SslHandler createSslHandler(ByteBufAllocator allocator, URI remote, TransportOptions options); static SSLContext createJdkSslContext(TransportOptions options); static SSLEngine createJdkSslEngine(URI remote, SSLContext context, TransportOptions options); static SslContext createOpenSslContext(TransportOptions options); static SSLEngine createOpenSslEngine(ByteBufAllocator allocator, URI remote, SslContext context, TransportOptions options); }
TransportSupport { public static SslContext createOpenSslContext(TransportOptions options) throws Exception { try { String contextProtocol = options.getContextProtocol(); LOG.trace("Getting SslContext instance using protocol: {}", contextProtocol); KeyManagerFactory keyManagerFactory = loadKeyManagerFactory(options, SslProvider.OPENSSL); TrustManagerFactory trustManagerFactory = loadTrustManagerFactory(options); SslContextBuilder builder = SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL); if (options.getContextProtocol().equals(TransportOptions.DEFAULT_CONTEXT_PROTOCOL)) { builder.protocols("TLSv1.2"); } else { builder.protocols(options.getContextProtocol()); } builder.keyManager(keyManagerFactory); builder.trustManager(trustManagerFactory); return builder.build(); } catch (Exception e) { LOG.error("Failed to create SslContext: {}", e, e); throw e; } }  static boolean isOpenSSLPossible(TransportOptions options); static SslHandler createSslHandler(ByteBufAllocator allocator, URI remote, TransportOptions options); static SSLContext createJdkSslContext(TransportOptions options); static SSLEngine createJdkSslEngine(URI remote, SSLContext context, TransportOptions options); static SslContext createOpenSslContext(TransportOptions options); static SSLEngine createOpenSslEngine(ByteBufAllocator allocator, URI remote, SslContext context, TransportOptions options);  }