### Question:
SSLUtils { public static SSLHandlerFactory createRestClientSSLEngineFactory(final Configuration config) throws Exception { SSLContext sslContext = createRestClientSSLContext(config); if (sslContext == null) { throw new IllegalConfigurationException("SSL is not enabled for REST endpoints."); } return new SSLHandlerFactory( sslContext, getEnabledProtocols(config), getEnabledCipherSuites(config), true, isRestSSLAuthenticationEnabled(config), -1, -1); }  static boolean isInternalSSLEnabled(Configuration sslConfig); static boolean isRestSSLEnabled(Configuration sslConfig); static boolean isRestSSLAuthenticationEnabled(Configuration sslConfig); static ServerSocketFactory createSSLServerSocketFactory(Configuration config); static SocketFactory createSSLClientSocketFactory(Configuration config); static SSLHandlerFactory createInternalServerSSLEngineFactory(final Configuration config); static SSLHandlerFactory createInternalClientSSLEngineFactory(final Configuration config); static SSLHandlerFactory createRestServerSSLEngineFactory(final Configuration config); static SSLHandlerFactory createRestClientSSLEngineFactory(final Configuration config); @Nullable static SSLContext createRestServerSSLContext(Configuration config); @Nullable static SSLContext createRestClientSSLContext(Configuration config);  }### Answer:
@Test public void testRESTClientSSL() throws Exception { Configuration clientConfig = createRestSslConfigWithTrustStore(); SSLHandlerFactory ssl = SSLUtils.createRestClientSSLEngineFactory(clientConfig); assertNotNull(ssl); }
@Test public void testRESTClientSSLDisabled() throws Exception { Configuration clientConfig = createRestSslConfigWithTrustStore(); clientConfig.setBoolean(SecurityOptions.SSL_REST_ENABLED, false); try { SSLUtils.createRestClientSSLEngineFactory(clientConfig); fail("exception expected"); } catch (IllegalConfigurationException ignored) {} }
@Test public void testRESTClientSSLMissingTrustStore() throws Exception { Configuration config = new Configuration(); config.setBoolean(SecurityOptions.SSL_REST_ENABLED, true); config.setString(SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD, "some password"); try { SSLUtils.createRestClientSSLEngineFactory(config); fail("exception expected"); } catch (IllegalConfigurationException ignored) {} }
@Test public void testRESTClientSSLMissingPassword() throws Exception { Configuration config = new Configuration(); config.setBoolean(SecurityOptions.SSL_REST_ENABLED, true); config.setString(SecurityOptions.SSL_REST_TRUSTSTORE, TRUST_STORE_PATH); try { SSLUtils.createRestClientSSLEngineFactory(config); fail("exception expected"); } catch (IllegalConfigurationException ignored) {} }
@Test public void testRESTClientSSLWrongPassword() throws Exception { Configuration clientConfig = createRestSslConfigWithTrustStore(); clientConfig.setString(SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD, "badpassword"); try { SSLUtils.createRestClientSSLEngineFactory(clientConfig); fail("exception expected"); } catch (Exception ignored) {} }