stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

Exception during keystore creation #59

Closed jensflorian closed 3 years ago

jensflorian commented 3 years ago

Expected Behavior

Keystore is created after entering IP and PW into bridge handler.

Current Behavior

No *.jks file is created. After setting log to trace I get this info:

2020-12-25 13:27:51.526 [INFO ] [internal.devices.bridge.BoschSslUtil] - Creating new keystore /Users/jensflorian/Downloads/openhab-RC1/userdata/etc/oss_openhab_binding_2eae8ca1-754d-41aa-a1e2-87d3dec7faa6.jks because it doesn't exist.
2020-12-25 13:27:51.527 [DEBUG] [internal.devices.bridge.BoschSslUtil] - Creating new keypair
2020-12-25 13:27:51.672 [DEBUG] [internal.devices.bridge.BoschSslUtil] - Creating a new self signed certificate: CN=oss_openhab_binding_2eae8ca1-754d-41aa-a1e2-87d3dec7faa6, O=openHAB, L=None, ST=None, C=None
2020-12-25 13:27:51.677 [DEBUG] [internal.devices.bridge.BoschSslUtil] - Adding keypair and self signed certificate to keystore
2020-12-25 13:27:51.678 [DEBUG] [internal.devices.bridge.BoschSslUtil] - Adding Issuing CA to keystore
2020-12-25 13:27:51.678 [DEBUG] [internal.devices.bridge.BoschSslUtil] - Exception during keystore creation Could not parse certificate: java.io.IOException: Stream closed

Possible Solution

Create jks file manually (how?)

Steps to Reproduce (for Bugs)

Reproducible. I assume creation of jks file in OsX shell may be different from RaspberryPI.

Your Environment

GerdZanker commented 3 years ago

The Exception is causes by this line of code https://github.com/stefan-kaestle/openhab2-addons/blob/59165a5bc2c822910658bc181a18f0bc6ac987eb/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/bridge/BoschSslUtil.java#L167 But I have currently no glue why loading the PEM resource file from the Jar fails.

Creating a jks file manually is not really possible - you need to follow all the steps and use exactly the same values as the code in createKeyStore().

GerdZanker commented 3 years ago

After tests with my own setup (OH3, RPi Linux, Bosch SHC v1.0 Beta 4) I can confirm that this a reproducible bug and not related to OsX. I get exactly the same log traces.

GerdZanker commented 3 years ago

I was able to find the changes in 82ab755eae34da6a77bbced0d921a60ba41e7a7d causing the problem that the *.pem files can't be loaded anymore from the Jar and will provide soon a bug fix branch where the two resources will be located inside the now expected package org.openhab.binding.boschshc.internal.devices.bridge.

Thanks a lot @jensflorian for reporting the bug and for the very useful trace.

FYI @coeing, we need to include this fix into the openhab PR

jensflorian commented 3 years ago

Thanks for the update, will be happy to test again after the fix.

GerdZanker commented 3 years ago

Fixed with PR #60 and will be part of v1.0 of the Bosch SHC binding.