code: public HttpURLConnection openConnection(URL url) throws IOException, NoSuchAlgorithmException, KeyManagementException, BugError {
  		if (!isSecure(url.getProtocol())) {
  			log.debug("Open HTTP connection with |%s|.", url);
  			return (HttpURLConnection) url.openConnection();
  		}
  
  		log.debug("Open %sauthenticated HTTP secure connection with |%s|.", keyManagers == null ? "not " : "", url);
  
  		SSLContext sslContext = SSLContext.getInstance("TLS");
  		sslContext.init(keyManagers, trustManagers, null);
  
  		HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
  		connection.setSSLSocketFactory(sslContext.getSocketFactory());
  		return connection;
  	}
docs: Create and open a HTTP(S) connection with requested URL. URL protocol is used to detect if requested connection should be
  secure. For secure connections takes care to initialize SSL context.
  
  @param url the URL to open connection with.
  @return HTTP connection opened with requested <code>url</code>.
  @throws IOException if attempt to connected remote URL fails due to networking or remote host problems,
  @throws NoSuchAlgorithmException if algorithms used by certificate are not supported,
  @throws KeyManagementException if TLS handshake fails because of invalid or expired certificates.
  @throws BugError if given URL protocol is not <code>http</code> or <code>https</code>.