code: public static void setNoValidate(HttpsURLConnection connection, String[] acceptedIssuers) {
          SSLContext sc;
          try {
              // Using "SSL" below means protocols: SSLv3, TLSv1
              sc = SSLContext.getInstance("SSL");
              sc.init(null, getNonValidatingTrustManagers(acceptedIssuers), new java.security.SecureRandom());
              connection.setSSLSocketFactory(sc.getSocketFactory());
              connection.setHostnameVerifier(SSLUtils.ALLHOSTSVALID_HOSTNAMEVERIFIER);
          } catch (NoSuchAlgorithmException ex) {
              // Don't think this will ever happen. Hence we do not forward it.
              LOGGER.log(Level.SEVERE, "Algorithm SSL not found.", ex);
          } catch (KeyManagementException ex) {
              // Don't think this will ever happen. Hence we do not forward it.
              LOGGER.log(Level.SEVERE, "Error initializing SSL security context.", ex);
          }
      }
docs: Changes the HTTPS connection so that it will not validate the endpoint's
  certificates. Also it will not require the URL hostname to match the
  common name presented by the endpoint's certificate. This method should
  be called <i>before</i> a connection is made on the {@code connection}
  object.
  
  <p>
  This method is equivalent to <code>--no-check-certificate</code> option when
  using the Unix/Linux <code>wget</code> command line tool.
  
  <p>
  As an additional feature the issuer of the certificate can be checked
  to match (any of) a certain string. If - for example - you create
  a self-signed certificate then you decide the 'issuer organization'
  yourself and the issuer organization name you used when you created the
  certificate can then be validated here. This provides a
  little extra security than simply accepting any type of certificate.
  
  
  @param connection connection to change (must not yet be connected)
  @param acceptedIssuers accept only a certificate from one of these issuer
  organizations. Checks against the Organization (O) field in the 'Issued
  By' section of the server's certficate. This parameter provides some
  minimal security. A {@code null} means all issuer organizations are
  accepted.