Java Kubernetes client SSLHandshakeException extension (5) should not be presented in certificate_request
Asked Answered
E

3

25

I am getting "extension (5) should not be presented in certificate_request" when trying to run locally a Java Kubernetes client application which queries the Kubernetes cluster over a lube proxy connection. Any thoughts? Thanks in advance

  ApiClient client = null;
    try {
        client = Config.defaultClient();
        //client.setVerifyingSsl(false);
    } catch (IOException e) {
        e.printStackTrace();
    }
    Configuration.setDefaultApiClient(client);

    CoreV1Api api = new CoreV1Api();
    V1PodList list = null;
    try {
        list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
    } catch (ApiException e) {
        e.printStackTrace();
    }
    for (V1Pod item : list.getItems()) {
        System.out.println(item.getMetadata().getName());
    }
Epps answered 21/3, 2020 at 16:10 Comment(0)
C
52

Which version of Java are you using?

JDK 11 onwards have support for TLS 1.3 which can cause the error extension (5) should not be presented in certificate_request.

Add -Djdk.tls.client.protocols=TLSv1.2 to the JVM args to make it use 1.2 instead.

There is an issue on Go lang relating to this https://github.com/golang/go/issues/35722 and someone there also posted to disable TLS 1.3 on the Java side

Caenogenesis answered 10/4, 2020 at 15:49 Comment(1)
for people using Intellij IDEA IDE, you can add -Djdk.tls.client.protocols=TLSv1.2 to the VM options text field in Edit configurations -> Configuration tab -> Environment sectionSeep
I
16

Alternatively, upgrade your JDK to a more recent version to fix the problem.

Some min versions with this fix are: openjdk8u272, 11.0.7, 14.0.2

Inflow answered 28/10, 2020 at 14:0 Comment(1)
I had the exact same issue as OP on 11.0.6, upgrading to 11.0.11 fixed it immediately. Thanks!Sanalda
T
1

Instead of connecting via kubectl proxy connect to Kubernetes API Server directly from the application by providing a kubeconfig file to the Java client.

Typhon answered 21/3, 2020 at 17:30 Comment(1)
Thanks, however, I do not always have that option.Epps

© 2022 - 2024 — McMap. All rights reserved.