Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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());
    }
like image 418
Alexander F Avatar asked Mar 21 '20 16:03

Alexander F


3 Answers

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

like image 123
zcourts Avatar answered Oct 25 '22 01:10

zcourts


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

like image 14
sebnukem Avatar answered Oct 25 '22 01:10

sebnukem


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

like image 1
Arghya Sadhu Avatar answered Oct 25 '22 00:10

Arghya Sadhu