Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KubernetesClientException: JcaPEMKeyConverter is provided by BouncyCastle, an optional dependency. #4251

Closed
PulLa1 opened this issue Jul 5, 2022 · 9 comments

Comments

@PulLa1
Copy link

PulLa1 commented Jul 5, 2022

Describe the bug

Exception in thread "main" io.fabric8.kubernetes.client.KubernetesClientException: JcaPEMKeyConverter is provided by BouncyCastle, an optional dependency. To use support for EC Keys you must explicitly add this dependency to classpath.
at io.fabric8.kubernetes.client.internal.CertUtils.handleECKey(CertUtils.java:164)
at io.fabric8.kubernetes.client.internal.CertUtils.loadKey(CertUtils.java:134)
at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:112)
at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:247)
at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:153)
at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:147)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.applyCommonConfiguration(HttpClientUtils.java:204)
at io.fabric8.kubernetes.client.okhttp.OkHttpClientFactory.createHttpClient(OkHttpClientFactory.java:89)
at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:164)
at io.fabric8.kubernetes.client.BaseClient.(BaseClient.java:48)
at io.fabric8.kubernetes.client.BaseClient.(BaseClient.java:40)
at io.fabric8.kubernetes.client.BaseKubernetesClient.(BaseKubernetesClient.java:151)
at io.fabric8.kubernetes.client.DefaultKubernetesClient.(DefaultKubernetesClient.java:34)
at com.yz.zk.K8sDemo.main(K8sDemo.java:17)

Fabric8 Kubernetes Client version

5.12.2

Steps to reproduce

I try to connect k3s by kubeconfig。
this is my kubectl command:
image

Expected behavior

public class K8sDemo {

public static void main(String[] args) {
    System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "/myroot/.kube/k3s.yaml");
    DefaultKubernetesClient client = new DefaultKubernetesClient();
}

}

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.22.3@latest

Environment

macOS

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

@PulLa1
Copy link
Author

PulLa1 commented Jul 5, 2022

Ok I found the bug:java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
append maven to solve the problem:

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.59</version>
    </dependency>

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>1.59</version>
    </dependency>

@PulLa1
Copy link
Author

PulLa1 commented Jul 5, 2022

but i found the dependent in pom。
image

@rohanKanojia
Copy link
Member

We need to add documentation about it. There is a pull request open that adds an FAQ about it #4237 .

Could you please review this and see if it's okay?

@stale
Copy link

stale bot commented Oct 17, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Oct 17, 2022
@divick
Copy link

divick commented Oct 19, 2022

I get the same issue when using spark-submit with k8s cluster and using the examples in the binary only distribution of spark directly downloaded from official spark repo. I am not sure where should these dependency be added? In the pom.xml for spark sources and doing a rebuild?

@stale stale bot removed the status/stale label Oct 19, 2022
@stale
Copy link

stale bot commented Jan 17, 2023

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Jan 17, 2023
@stale stale bot closed this as completed Jan 24, 2023
@martinwunderlich-celonis

Hello, sorry for posting to the closed issue, but I have a related problem: Is there a way to use the fabric8 Kubernetes Client without BouncyCastle? I'm getting the following error:

io.fabric8.kubernetes.client.KubernetesClientException: JcaPEMKeyConverter is provided by BouncyCastle, an optional dependency. To use support for EC Keys you must explicitly add this dependency to classpath.

Due to restrictions in my project, I cannot add BC as a direct dependency.

@shawkins
Copy link
Contributor

@martinwunderlich-celonis see #6008

@martinwunderlich-celonis

@shawkins Thanks again. I am happy to confirm that removing the Bouncycastle library works when I upgrade the fabric8 client from 6.13.1 to 7.0-SNAPSHOT (built locally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants