protected HttpURLConnection getConnection(URL url) throws IOException {
    URLConnection connection = url.openConnection();

    if (!setupTruststoreForHttps) {
      HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;

      // Create a trust manager that does not validate certificate chains
      TrustManager[] trustAllCerts = new TrustManager[] {
          new TrustAllManager()
      };

      // Ignore differences between given hostname and certificate hostname
      HostnameVerifier hostnameVerifier = new TrustAllHostnameVerifier();
      // Install the all-trusting trust manager
      try {
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new SecureRandom());
        httpsConnection.setSSLSocketFactory(sc.getSocketFactory());
        httpsConnection.setHostnameVerifier(hostnameVerifier);
      } catch (NoSuchAlgorithmException | KeyManagementException e) {
        throw new IllegalStateException("Cannot create unverified ssl context.", e);
      }
    }

    return (HttpURLConnection) connection;
  }
Utility method to append a new cookie value to an existing list of cookies.

@param cookies    the semicolon separated list of cookie values
@param newCookie  a new cookie value to be appended.

@return the new list of cookie values
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java