Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@

package com.cloud.kubernetes.cluster.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.security.SecureRandom;
import java.util.stream.Collectors;

import org.apache.commons.io.IOUtils;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;

import org.apache.cloudstack.utils.security.SSLUtils;
import org.apache.log4j.Logger;

import com.cloud.kubernetes.cluster.KubernetesCluster;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
import com.cloud.utils.StringUtils;
import com.cloud.utils.nio.TrustAllManager;
import com.cloud.utils.ssh.SshHelper;
import com.google.common.base.Strings;

Expand Down Expand Up @@ -218,7 +226,13 @@ public static boolean isKubernetesClusterServerRunning(final KubernetesCluster k
boolean k8sApiServerSetup = false;
while (System.currentTimeMillis() < timeoutTime) {
try {
String versionOutput = IOUtils.toString(new URL(String.format("https://%s:%d/version", ipAddress, port)), StringUtils.getPreferredCharset());
final SSLContext sslContext = SSLUtils.getSSLContext();
sslContext.init(null, new TrustManager[]{new TrustAllManager()}, new SecureRandom());
URL url = new URL(String.format("https://%s:%d/version", ipAddress, port));
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we configure it to ignore ssl cert validation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and get more static analysis reports as issues?

con.setSSLSocketFactory(sslContext.getSocketFactory());
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String versionOutput = br.lines().collect(Collectors.joining());
if (!Strings.isNullOrEmpty(versionOutput)) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Kubernetes cluster ID: %s API has been successfully provisioned, %s", kubernetesCluster.getUuid(), versionOutput));
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.