diff --git a/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj b/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj
index f913d1b5..f2d803b8 100644
--- a/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj
+++ b/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/KubernetesClient.Models/KubernetesClient.Models.csproj b/src/KubernetesClient.Models/KubernetesClient.Models.csproj
index 3c878a91..a96a23d7 100644
--- a/src/KubernetesClient.Models/KubernetesClient.Models.csproj
+++ b/src/KubernetesClient.Models/KubernetesClient.Models.csproj
@@ -13,6 +13,6 @@
-
+
diff --git a/src/KubernetesClient/Kubernetes.ConfigInit.cs b/src/KubernetesClient/Kubernetes.ConfigInit.cs
index 762b61f6..7fc808b9 100644
--- a/src/KubernetesClient/Kubernetes.ConfigInit.cs
+++ b/src/KubernetesClient/Kubernetes.ConfigInit.cs
@@ -72,21 +72,19 @@ private void InitializeFromConfig(KubernetesClientConfiguration config)
}
else
{
- if (CaCerts == null)
+ if (CaCerts != null)
{
- throw new KubeConfigException("A CA must be set when SkipTlsVerify === false");
- }
-
#if NET5_0_OR_GREATER
- HttpClientHandler.SslOptions.RemoteCertificateValidationCallback =
+ HttpClientHandler.SslOptions.RemoteCertificateValidationCallback =
#else
- HttpClientHandler.ServerCertificateCustomValidationCallback =
+ HttpClientHandler.ServerCertificateCustomValidationCallback =
#endif
- (sender, certificate, chain, sslPolicyErrors) =>
- {
- return CertificateValidationCallBack(sender, CaCerts, certificate, chain,
- sslPolicyErrors);
- };
+ (sender, certificate, chain, sslPolicyErrors) =>
+ {
+ return CertificateValidationCallBack(sender, CaCerts, certificate, chain,
+ sslPolicyErrors);
+ };
+ }
}
}
diff --git a/src/KubernetesClient/KubernetesClient.csproj b/src/KubernetesClient/KubernetesClient.csproj
index 66da7e37..500ee520 100644
--- a/src/KubernetesClient/KubernetesClient.csproj
+++ b/src/KubernetesClient/KubernetesClient.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj b/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj
index 43a12e84..1b4f57e7 100644
--- a/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj
+++ b/src/LibKubernetesGenerator/LibKubernetesGenerator.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj b/tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj
index fa32b3df..3e18c003 100644
--- a/tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj
+++ b/tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
index 8849a85a..b6d2ecdd 100644
--- a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
+++ b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs b/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
index ed664fb3..97684483 100644
--- a/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
+++ b/tests/KubernetesClient.Tests/KubernetesClientConfigurationTests.cs
@@ -138,6 +138,20 @@ public void CheckClusterTlsSkipCorrectness()
Assert.True(cfg.SkipTlsVerify);
}
+ ///
+ /// Checks that a KubeConfigException is not thrown when no certificate-authority-data is set and user do not require tls
+ /// skip
+ ///
+ [Fact]
+ public void CheckClusterTlsNoSkipCorrectness()
+ {
+ var fi = new FileInfo("assets/kubeconfig.tls-no-skip.yml");
+ var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(fi);
+ Assert.NotNull(cfg.Host);
+ Assert.Null(cfg.SslCaCerts);
+ Assert.False(cfg.SkipTlsVerify);
+ }
+
///
/// Checks that a KubeConfigException is thrown when the cluster defined in clusters and contexts do not match
///
diff --git a/tests/KubernetesClient.Tests/assets/kubeconfig.tls-no-skip.yml b/tests/KubernetesClient.Tests/assets/kubeconfig.tls-no-skip.yml
new file mode 100644
index 00000000..fe101ec3
--- /dev/null
+++ b/tests/KubernetesClient.Tests/assets/kubeconfig.tls-no-skip.yml
@@ -0,0 +1,22 @@
+# Sample file based on https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/
+# WARNING: File includes minor fixes
+---
+current-context: federal-context
+apiVersion: v1
+clusters:
+- cluster:
+ insecure-skip-tls-verify: false
+ server: https://horse.org:443
+ name: horse-cluster
+contexts:
+- context:
+ cluster: horse-cluster
+ namespace: chisel-ns
+ user: green-user
+ name: federal-context
+kind: Config
+users:
+- name: green-user
+ user:
+ password: secret
+ username: admin