21 Commits

Author SHA1 Message Date
Boshi Lian
1f8e5da0c2 Update certificate validation to use custom trust store for .NET 5.0+ (#1653)
* Update certificate validation to use custom trust store for .NET 5.0 and greater

* Update src/KubernetesClient/Kubernetes.ConfigInit.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update apiserver-pfx-data.txt with new certificate data

* Update tests/KubernetesClient.Tests/CertificateValidationTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Brendan Burns <5751682+brendandburns@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-27 05:48:09 -07:00
cb
d8da943375 Support TLS Server Name overrides in kubeconfig (#1282)
The client should support tls-server-name just like client-go and kubectl.  See https://github.com/kubernetes/kubernetes/pull/88769
2023-04-28 16:50:16 -07:00
Marcus Bowyer
729b10c731 Use the system certificate store if no certificates are specified. (#1261)
* Use the system certificate store if no certificates are specified.

* Don't use ServerCertificateCustomValidationCallback when no CA is set
2023-04-18 16:36:45 -07:00
KLazarov
877587e898 Updated CertificateValidationCallBack to build the CaCert bundle with respect to the rootChain certs to verify that they are correct. (#860)
* Updated CertificateValidationCallBack to build the CaCert bundle with respect to the rootChain certs to verify that they are correct.

* Added a test cases and assets for when all the certs files are in the same file.

* Removed the hardcoded first cert as the chosen root cert
2022-05-23 20:07:10 -07:00
Boshi Lian
3643250f40 use net5 certificate api instead of 3rd api (#733)
* use net api for cert loading

* codeql happy?
2021-10-20 06:57:58 -07:00
Jarrett Confrey
ac0f43b576 fix: oidc (#633)
* fix: oidc

* revert: verbose oidc logs

* fix: actually commit changes

* chore: cleanup var name

* chore: address pr feedback
2021-05-24 09:33:39 -07:00
Alex Meyer-Gleaves
d48e93c1f6 Support IgnoreUnmatchedProperties in YAML serialization (#574)
* Support IgnoreUnmatchedProperties in YAML serialization

* Remove unnecessary null-conditional operator
2021-03-02 12:35:20 -08:00
Frederik Carlier
4e58609159 Support wildcard IPv4 and IPv6 addresses (#550)
Some tools can generate kubeconfig files which use wildcard IPv4 or IPv6 addresses. For example, using k3d with --api-server=https://0.0.0.0:6433/ would generate a kubeconfig file like this:

```
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: (...)
    server: https://0.0.0.0:6433
  name: k3d-k3s-default
```

Standard Kubernetes tools (like kubectl or Helm) correctly parse the 0.0.0.0 IP address and transform it 127.0.0.1; 3rd party tools like curl or wget will do the same on Unix systems.

This is default behavior on Unix but not on Windows. As a result, the .NET Kubernetes client will fail to work with kubeconfig files like this and you'll get HTTP exceptions.

Go has explicit workarounds for this (see 1a0b1cca4c), and this PR attemps to replicate these workarounds in the .NET client.
2021-01-28 00:19:48 -08:00
Frederik Carlier
6f5706d753 Fix kubeconfig extension handling (#556)
Extensions on kubeconfig files are stored as a list of NamedExtension objects, not a dictionary.
2021-01-27 08:57:40 -08:00
Shihang Zhang
6d5fefdbab add TokenFileAUth which reloads token if it expires (#440) 2020-05-18 15:01:36 -07:00
Andrew Stakhov
ae9dd04a2e Allow token refresh for GCP (#402) 2020-04-28 15:34:25 -07:00
Justin Kotalik
324a3e72fd Allow KUBECONFIG environment variable to point to multiple files (#411)
* Allow KUBECONFIG environment variable to point to multiple files

* Add more tests, add API (can make internal if necessary)

* test

* allow passing in env var

* small amount of feedback

* Feedback

* Nits

* Some extra tests and comments
2020-04-22 15:17:45 -07:00
Ryan Nowak
da3bff5b3e Use value from ContextDetails to populate Namespace (#373)
* Use value from ContextDetails to populate Namespace

This is a fix for: #372

This change uses the value from ContextDetails.Namespace to populate
KubernetesClientConfiguration.Namespace.

The issue is there's a Namespace property on both Context and ContextDetails
 - The property on Context is used today
 - The property on ContextDetails is not
 - The property on ContextDetails maps to the actual yaml config

* Obsolete Context.Namespace

This property doesn't map to anything in the YAML and thus will never be
set. Other clients I checked (java, golang) don't look for a property
at this level.

I think this was likely a mistake, and it should be obsoleted because
it will never be populated.

Example:

```yaml
contexts:
- context:
    cluster: ...
    namespace: ... # this is ContextDetails.Namespace
    user: ...
  name: foo
```

```yaml
contexts:
- context:
    cluster: ...
    namespace: ...
    user: ...
  name: foo
  namespace: ... # this is Context.Namespace
```
2020-03-17 09:48:23 -07:00
etchang
9bdaf132d4 Add bundle certificate support (#253)
* initial

* add some comments

* cleanup

* var

* Use X509Certificate2cCollection

* add missing asset files

* address comments
2019-03-11 06:39:28 -07:00
Brendan Burns
948d78c1bd Fix elliptic curve certs and add a unit test (#243)
* Fix a elipitic curve certs and add a unit test.

* Address comments.

* Change the key to be OSX compatible.
2019-02-27 10:45:21 -08:00
Boshi Lian
406df57f9d pretend to support chain (#245) 2019-02-15 11:57:24 -08:00
Boshi Lian
1600e44b00 generate for 1.13 (#223)
* generate for 1.13 and bump ver to 1.4

* fix examples for 1.13

* update outdated cert
2018-12-11 21:10:39 -08:00
Aaron Roney
b7f79c924f Remove requirement for certificate authority and certificate authority data in kubeconfig. (#222)
* Remove requirement for certificate authority data in kubeconfig.

* Update src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs

Update casing of `URL` at @itowlson suggestion.

Co-Authored-By: twitchax <twitchax@gmail.com>
2018-12-11 21:08:55 -08:00
David Orbelian
6eb5555145 Fix issue with X509VerificationFlags.AllowUnknownCertificateAuthority behavior (#174)
* Fix issue with X509VerificationFlags.AllowUnknownCertificateAuthority behavior

* Add CertificateValidationTests
2018-06-13 10:55:41 -07:00
Frederik Carlier
d90289a094 Support relative paths in Kubernetes configuration files (#141)
* Support relative paths in Kubernetes configuration files

* Filename -> FileName

* Filename -> FileName

* KuberentesClientConfiguration: Allow the user to opt-out of the mechanism which resolves relative paths in the configuration file.

* Update unit tests

* Fix test
2018-04-26 21:13:48 -07:00
Adam Friedman
ea62ca00e0 Move projects to subdirectories of /src and /tests (#134)
kubernetes-client/csharp#127
2018-04-04 22:13:45 -07:00