Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 16 additions & 10 deletions util/src/main/java/io/kubernetes/client/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,22 @@ public static ApiClient fromConfig(Reader input) {
ex.printStackTrace();
}

// It's silly to have to do it in this order, but each SSL setup
// consumes the CA cert, so if we do this before the client certs
// are injected the cert input stream is exhausted and things get
// grumpy'
String caCert = config.getCertificateAuthorityData();
String caCertFile = config.getCertificateAuthorityFile();
try {
client.setSslCaCert(SSLUtils.getInputStreamFromDataOrFile(caCert, caCertFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
if (config.verifySSL()) {
// It's silly to have to do it in this order, but each SSL setup
// consumes the CA cert, so if we do this before the client certs
// are injected the cert input stream is exhausted and things get
// grumpy'
String caCert = config.getCertificateAuthorityData();
String caCertFile = config.getCertificateAuthorityFile();
if (caCert != null || caCertFile != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we fail if config.verifySSL() is true and both of these two are null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because you could be using a legit well-known CA issued cert, in which case you don't have to supply your own CA root.

try {
client.setSslCaCert(SSLUtils.getInputStreamFromDataOrFile(caCert, caCertFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
} else {
client.setVerifyingSsl(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also set this to true in the previous block. just to be bullet proof (e.g. somebody loading config with verifySSL false and then again with it set to true.

Copy link
Contributor Author

@brendandburns brendandburns Jun 25, 2017

Choose a reason for hiding this comment

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

This call is static and always creates both a new KubeConfig object and returns a new client, so I don't think that is a risk.

}

String token = config.getAccessToken();
Expand Down
7 changes: 7 additions & 0 deletions util/src/main/java/io/kubernetes/client/util/KubeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ public String getAccessToken() {
return null;
}

public boolean verifySSL() {
if (currentCluster.containsKey("insecure-skip-tls-verify")) {
return ! ((Boolean) currentCluster.get("insecure-skip-tls-verify")).booleanValue();
}
return true;
}

private static String getData(Map<String, Object> obj, String key) {
if (obj == null) {
return null;
Expand Down