File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed
util/src/main/java/io/kubernetes/client/util Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -114,16 +114,22 @@ public static ApiClient fromConfig(Reader input) {
114114 ex .printStackTrace ();
115115 }
116116
117- // It's silly to have to do it in this order, but each SSL setup
118- // consumes the CA cert, so if we do this before the client certs
119- // are injected the cert input stream is exhausted and things get
120- // grumpy'
121- String caCert = config .getCertificateAuthorityData ();
122- String caCertFile = config .getCertificateAuthorityFile ();
123- try {
124- client .setSslCaCert (SSLUtils .getInputStreamFromDataOrFile (caCert , caCertFile ));
125- } catch (FileNotFoundException e ) {
126- e .printStackTrace ();
117+ if (config .verifySSL ()) {
118+ // It's silly to have to do it in this order, but each SSL setup
119+ // consumes the CA cert, so if we do this before the client certs
120+ // are injected the cert input stream is exhausted and things get
121+ // grumpy'
122+ String caCert = config .getCertificateAuthorityData ();
123+ String caCertFile = config .getCertificateAuthorityFile ();
124+ if (caCert != null || caCertFile != null ) {
125+ try {
126+ client .setSslCaCert (SSLUtils .getInputStreamFromDataOrFile (caCert , caCertFile ));
127+ } catch (FileNotFoundException e ) {
128+ e .printStackTrace ();
129+ }
130+ }
131+ } else {
132+ client .setVerifyingSsl (false );
127133 }
128134
129135 String token = config .getAccessToken ();
Original file line number Diff line number Diff line change @@ -171,6 +171,13 @@ public String getAccessToken() {
171171 return null ;
172172 }
173173
174+ public boolean verifySSL () {
175+ if (currentCluster .containsKey ("insecure-skip-tls-verify" )) {
176+ return ! ((Boolean ) currentCluster .get ("insecure-skip-tls-verify" )).booleanValue ();
177+ }
178+ return true ;
179+ }
180+
174181 private static String getData (Map <String , Object > obj , String key ) {
175182 if (obj == null ) {
176183 return null ;
You can’t perform that action at this time.
0 commit comments