java icon indicating copy to clipboard operation
java copied to clipboard

ConfigBuilder.withClientKeyData is broken

Open if6was9 opened this issue 8 years ago • 1 comments

ConfigBuilder.withClientKeyData() is broken in 3.1.8.

withClientCertData and withCaCertData work just fine.

The following code snippit shows the problem and the workaround.

boolean useWorkaround = true;
if (useWorkaround) {
    File tempWorkaroundFile = null;
    try {
        tempWorkaroundFile = java.nio.file.Files.createTempFile("workaround", "tmp").toFile();
        Files.write(key, tempWorkaroundFile, Charsets.UTF_8);
        configBuilder = configBuilder.withClientCertFile(tempWorkaroundFile.getAbsolutePath());
    } finally {
        tempWorkaroundFile.delete();
    }
 } else {
    configBuilder = configBuilder.withClientKeyData(key);
}

The problem manifests as:

Caused by: java.io.IOException: PEM is invalid: no begin marker
	at io.fabric8.kubernetes.client.internal.CertUtils.decodePem(CertUtils.java:220)
	at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:105)
	at io.fabric8.kubernetes.client.internal.CertUtils.createKeyStore(CertUtils.java:196)
	at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:127)
	at io.fabric8.kubernetes.client.internal.SSLUtils.keyManagers(SSLUtils.java:121)
	at io.fabric8.kubernetes.client.utils.HttpClientUtils.createHttpClient(HttpClientUtils.java:64)
	... 38 more

ConfigBuilder appears to be auto-generated so it is not clear to me how to fix this.

if6was9 avatar Feb 17 '18 11:02 if6was9

is this fabric8 kubernetes java client, then you raised issue in wrong repo. https://github.com/fabric8io/kubernetes-client/issues

karthikkondapally avatar Feb 17 '18 11:02 karthikkondapally