Sorry for the late answer. Please let me answer your first topic about the keytool. I have only one keytool in my system (not one for each JRT). The /etc/alternatives/keytool is a symlink to /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/keytool. So I think, this is the correct version for JRT8 and this version I was used to install the certificate.
Now I had time for a test without trustAllCerts. The test was failed with exception, that no known certificate was found. I tried 2 versions. First version without this lines of code:
//SSLContext sc = SSLContext.getInstance(āTLSā); //sc.init(null, trustAllCerts, new java.security.SecureRandom()); //javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
Second version without a trustAllCerts object:
SSLContext sc = SSLContext.getInstance(āTLSā);
sc.init(null, null, new java.security.SecureRandom());
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
Both version trows the same exeception. So my statement is, that I must set the path to the keystore inside the code AND I must trustAllCerts. Here is the exception:
20:55:51.593 [DEBUG] [ig.internal.data.TankerkoenigService] - Error in executeGetRequest:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)[:1.8.0_65]
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)[:1.8.0_65]
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)[:1.8.0_65]
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)[:1.8.0_65]
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)[:1.8.0_65]
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)[:1.8.0_65]
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)[:1.8.0_65]
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)[:1.8.0_65]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)[:1.8.0_65]
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)[:1.8.0_65]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)[:1.8.0_65]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)[:1.8.0_65]
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)[:1.8.0_65]
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)[:1.8.0_65]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)[:1.8.0_65]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)[:1.8.0_65]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)[:1.8.0_65]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.executeGetRequest(TankerkoenigService.java:120)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getTankerkoenigDetailResult(TankerkoenigService.java:191)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getStationDetailData(TankerkoenigService.java:61)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.handler.StationHandler.updateDetailData(StationHandler.java:156)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.handler.StationHandler$1.run(StationHandler.java:94)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)[:1.8.0_65]
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)[:1.8.0_65]
at sun.security.validator.Validator.validate(Validator.java:260)[:1.8.0_65]
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)[:1.8.0_65]
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)[:1.8.0_65]
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)[:1.8.0_65]
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)[:1.8.0_65]
ā¦ 24 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146)[:1.8.0_65]
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)[:1.8.0_65]
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)[:1.8.0_65]
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)[:1.8.0_65]
ā¦ 30 more
20:55:51.593 [DEBUG] [.tankerkoenig.handler.StationHandler] - Caught exception in ScheduledExecutorService of TankerkoenigHandler. RuntimeExcetion: {}
java.lang.NullPointerException
at org.openhab.binding.tankerkoenig.handler.StationHandler.updateDetailData(StationHandler.java:158)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.handler.StationHandler$1.run(StationHandler.java:94)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
20:55:51.622 [DEBUG] [ig.internal.data.TankerkoenigService] - getTankerkoenigDetailResult jsonData : null
20:55:51.624 [DEBUG] [.tankerkoenig.handler.StationHandler] - Caught exception in ScheduledExecutorService of TankerkoenigHandler. RuntimeExcetion: {}
java.lang.NullPointerException
at org.openhab.binding.tankerkoenig.handler.StationHandler.updateDetailData(StationHandler.java:158)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at org.openhab.binding.tankerkoenig.handler.StationHandler$1.run(StationHandler.java:94)[251:org.openhab.binding.tankerkoenig:2.2.0.201711141822]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Iām be with you, that trustAllCerts is not an option for official. But I think, itās a good idea, to provide for all things a configuration param in the bridge (KeystorePath, KeystorePass, CertAlias, TrustAllCerts, UseSimpleMode (HttpUtils)
Currently I have not enough free space on my pi. Before I can make a java update, I must buy a bigger sdcard and move the system. I donāt know, when I have time for this. Sorry.
@opus as far as I read and find our tankerkoening uses Letās encrypt and according to the source above the certificates are natively supported starting from version 101. If anyone else could test this we could update the readme to include it.
I checked there server and viewed their certificate saw that it was lets encrypt, I remember others having problems with them to because they have their own root certificate.
I was going to refer to that problem with myopenhab and the minimum required java version, in order not to suggest such a change in the readme. But it looks like this kind of setup (with older java versions) is sticking around a little longer. Soā¦
If the error of @Dojokun is related to that, the initial problem would be āsolvedā.
I canāt test (at least not in here) such a regression since the notebook I have in here is just handling what is has, end of life is expected on Tuesday.
Iāve a new and bigger SD card installed and Iāve updated my Java to the version:
java version "1.8.0_151"
Javaā¢ SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpotā¢ Client VM (build 25.151-b12, mixed mode)
When I try the official Tankerkoenig Binding (Version 2.1.0) I get for the most stations a valid result, but only by one I get an exception. I remember me, that JĆ¼rgen has fixed this problem with the null value in the response JSON in an unofficial version.
@JĆ¼rgen:
Right?
I think, we can publish, that the java version is important for the binding. If the exception is fixed in an official binding, I will used it. Until then, I use my private binding.
13:53:42.812 [DEBUG] [ig.internal.data.TankerkoenigService] - getTankerkoenigDetailResult jsonData : {āokā:true,ālicenseā:āCC BY 4.0 - https://creativecommons.tankerkoenig.deā,ādataā:āMTS-Kā,āstatusā:āokā,āstationā:{āidā:āb4d96bec-b357-439e-bc21-d0fddd8ef843ā,ānameā:āKESSELSDORF, SACHSENALLEE.ā,ābrandā:āShellā,āstreetā:āSACHSENALLEE 1ā,āhouseNumberā:"",āpostCodeā:1723,āplaceā:āKESSELSDORFā,āopeningTimesā:[{ātextā:āt\u00e4glichā,āstartā:ā02:00:00ā,āendā:ā01:30:00ā}],āoverridesā:[],āwholeDayā:false,āisOpenā:true,āe5ā:1.369,āe10ā:null,ādieselā:1.209,ālatā:51.035035,ālngā:13.584056,āstateā:null}}
13:53:42.826 [DEBUG] [.tankerkoenig.handler.StationHandler] - Caught exception in ScheduledExecutorService of TankerkoenigHandler. RuntimeExcetion: {}
java.lang.UnsupportedOperationException: JsonNull
at com.google.gson.JsonElement.getAsDouble(JsonElement.java:204)[10:com.google.gson:2.3.1]
at org.openhab.binding.tankerkoenig.internal.serializer.CustomTankerkoenigDetailResultDeserializer.deserialize(CustomTankerkoenigDetailResultDeserializer.java:41)[256:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.internal.serializer.CustomTankerkoenigDetailResultDeserializer.deserialize(CustomTankerkoenigDetailResultDeserializer.java:1)[256:org.openhab.binding.tankerkoenig:2.1.0]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)[10:com.google.gson:2.3.1]
at com.google.gson.Gson.fromJson(Gson.java:810)[10:com.google.gson:2.3.1]
at com.google.gson.Gson.fromJson(Gson.java:775)[10:com.google.gson:2.3.1]
at com.google.gson.Gson.fromJson(Gson.java:724)[10:com.google.gson:2.3.1]
at com.google.gson.Gson.fromJson(Gson.java:696)[10:com.google.gson:2.3.1]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getTankerkoenigDetailResult(TankerkoenigService.java:92)[256:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getStationDetailData(TankerkoenigService.java:48)[256:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.handler.StationHandler.updateDetailData(StationHandler.java:133)[256:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.handler.StationHandler$1.run(StationHandler.java:90)[256:org.openhab.binding.tankerkoenig:2.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_151]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_151]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_151]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_151]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_151]
The āunofficialā version is the one that comes with the Snapshot version ( i.e. 2.2), didnāt I share the .jar of this updated binding in your original thread? You should also be able to use any of the .jars which I changed for you in order to have a longer TimeOut.
Reference your suggestion to mention the required Java Version in the docs of the binding, Yes, as already stated above, I will definitely put that into the docs.
In other words, I can āsolveā this thread (and you could mark your original thread as soved as well?)