private static SSLFactory createSSLFactory(TlsConfig tlsConfig, boolean insecureMode) {
    return createSSLFactory(
        tlsConfig.getKeyStoreType(), tlsConfig.getKeyStorePath(), tlsConfig.getKeyStorePassword(),
        tlsConfig.getTrustStoreType(), tlsConfig.getTrustStorePath(), tlsConfig.getTrustStorePassword(),
        null, null, true, tlsConfig.isInsecure() || insecureMode);
  }
@Test
  public void createSslFactoryInInsecureMode() {
    SecureRandom secureRandom = new SecureRandom();
    SSLFactory sslFactory = RenewableTlsUtils.createSSLFactory(KEYSTORE_TYPE, TLS_KEYSTORE_FILE_PATH, PASSWORD,
        TRUSTSTORE_TYPE, TLS_TRUSTSTORE_FILE_PATH, PASSWORD, "TLS", secureRandom, false, true);

    X509ExtendedTrustManager x509ExtendedTrustManager = sslFactory.getTrustManager().get();
    assertTrue(x509ExtendedTrustManager instanceof UnsafeX509ExtendedTrustManager);
    assertEquals(x509ExtendedTrustManager.getAcceptedIssuers().length, 0);

    sslFactory = RenewableTlsUtils.createSSLFactory(KEYSTORE_TYPE, TLS_KEYSTORE_FILE_PATH, PASSWORD,
        TRUSTSTORE_TYPE, TLS_TRUSTSTORE_FILE_PATH, PASSWORD, "TLS", secureRandom, true, true);
    ensurSslFactoryUseUnsafeTrustManager(sslFactory);
  }