openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

SamsungAC: ssl handshake error #2863

Closed ronny332 closed 7 years ago

ronny332 commented 9 years ago

Are there any known issue for the SamsungAC binding for newer models? In our house we have 3 Samsung devices working, 2 devices are from 2013 and the newest one was introduced in late 2014.

Both devices of 2013 are working (Samsung Flagship Jungfrau), but the newest one does not connect. Openhab is reporting

15:18:16.666 [DEBUG] [.b.s.internal.SamsungAcBinding:267  ] - java.lang.Exception: Cannot connect to 10.0.0.125:2878 : javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

A short curl test shows the same result. I can connect to both older devices, but not to the newest one.

A short wireshark debug recording is showing no "big" data frames anymore. Is it possible samsung has left the XML communication between the remote app and the device?

steintore commented 8 years ago

The procedure is that you'll get the InvalidAccount something. The you can respond with <Request Type="GetToken" /> And you should receive a token. If you get this far, then it the communication should be okay. You can try to get the state of everything by sending this command (after getting the token): <Request Type="DeviceState" DUID="{{MAC}}"></Request> (Replace {{MAC}} with the AC mac address

MrMerlino commented 8 years ago

ok With GetToken, turn AC on i receive the right token, but then with the DeviceState command i didn't receive answer I'll try again :)

MrMerlino commented 8 years ago

Ok was my fault :) Now works! cattura

After few seconds i receive this: <?xml version="1.0" encoding="utf-8" ?><Update Type="Status"><Status DUID="MACADDRESS" GroupID="AC" ModelID="AC"><Attr ID="AC_FUN_TEMPNOW" Value="19" /></Status></Update>

MrMerlino commented 8 years ago

Ok :) I'm so sorry but i'm really noob about this :D The right command was: <Request DUID="MACADDRESS" Type="DeviceState" />

And the AC Answer correclty :dancer:

Thanks to all man! We fixed the problem :) what a beautiful day!!!!!!!

next stop: block with iptables all communication of the AC with the samsung server....don't wont a new firmware update of our AC :)

Really thanks to all :) @luca-saggese @RemcoteWinkel @steintore

luca-saggese commented 8 years ago

MrMerlino, could you track the connections the ac is doing to samsung? i'm really worried of blocking any update to my system.

RemcoteWinkel commented 8 years ago

I have the current open connection, I guess this is for the service (control with phone)

tcp 192.168.1.147:54596 112.106.186.251:80

MrMerlino commented 8 years ago

Yes for sure.... I'll try to understand! But i'll come back at home on the last days of february!

luca-saggese commented 8 years ago

i've blocked all outgoing connection, the nice fact is that the ac sense it and sends a status update with AC_SG_INTERNET: Disconnected

voilà!

MrMerlino commented 8 years ago

So we wait for the new binding :) thanks to all :)

brunofosi commented 8 years ago

great news! i was starting to look for alternatives, like grab some kind of IR relay controllers, like the broadlink or the harmony

RemcoteWinkel commented 8 years ago

I have been creatively busy with the ac. I guessed that If I can use openssl to get XML, I can just as well get that into openhab. So here is a temporary failover to read (write I will do next) the airco information. You can use it until @steintore figures the java part out. I have only implemented power status, set temp status and current status but the example speaks for itself. You will also need to install some utilities like 'expect', and the exec binding. Here we go:

Create the certificate:

openssl pkcs12 -in ack14k_m.pfx -out cert.pem -nodes

Hit enter for password.

First a script to extract the data from the ac into an XML file, remember to put the cert.pem file you created in the same directory. It is also the directory for the output files. In my case /home/domo/ac

File:remco.exp

#!/usr/bin/expect 
set timeout 30
spawn openssl s_client -connect 192.168.1.181:2878  -cert  /home/domo/ac/cert.pem  -quiet
expect {<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>}  
send {<Request Type="Authtoken"><User Token="xxxxxx-xxx" /></Request>} 
send "\r"
expect "Okay" 
send {<Request Type="DeviceState" DUID="BC8CCD54xxxx"></Request>} 
send  "\r"
expect "</Device></DeviceState></Response>"
exit

Replace token en mac with appropriate values. Make the script executable chmod +x remco.exp

This will give you an XML file. So if we run this script from another script, we can store the xml, extract the values and inject them into openhab like this:

file:updateacremco.sh

/home/domo/ac/remco.exp >/home/domo/ac/remco.out
cat /home/domo/ac/remco.out | grep "DeviceState></Response>" > /home/domo/ac/remco.xml
cat  /home/domo/ac/remco.xml | awk -F"\"" '{print $26}' | xargs curl --silent -H "Content-Type: text/plain" http://localhost:8080/rest/items/r_ac_p_t -d  $1
cat  /home/domo/ac/remco.xml | awk -F"\"" '{print $38}'| xargs curl --silent -H "Content-Type: text/plain" http://localhost:8080/rest/items/r_ac_st_t -d  $1
cat  /home/domo/ac/remco.xml | awk -F"\"" '{print $56}' | xargs curl --silent -H "Content-Type: text/plain" http://localhost:8080/rest/items/r_ac_ct_t -d  $1

Make this executable as well. chmod +x updateacremco.sh

So now to use this in openhab I have the following items:

String r_ac_ct_t "Current temp  [%s]"
String r_ac_p_t " Power  [%s]"
String r_ac_st_t "Set temp  [%s]"

To get this update automatically I have a special switch. Every time this is set On or Off it puts things in motion:

Switch Aircoscript_r "Update" (Heatmiser, gDivers) { exec="OFF:sh /home/domo/ac/updateacremco.sh, ON:sh /home/domo/ac/updateacremco.sh"}

Set the file paths to match your own configuration. Lastly a rule is responsible for turning the switch on and off every couple of minutes:

rule "Every couple of minutes"
when
  Time cron "0 0/10 * * * ?"
  then
 if(AiroScript_r.state==ON) {
                sendCommand(Aircoscript_r, "OFF")
                }
         else {
                sendCommand(Aircoscript_r, "ON")
                }   
end

And yes, it is a long way around the issue, but at least I got my ac back in openhab. So for the time being a good workaround.

RemcoteWinkel commented 8 years ago

The following script can be called with parameters to control the ac, like for setting the temperature:

./setac.exp AC_FUN_TEMPSET 22

File:setac.exp

#!/usr/bin/expect 
set timeout 300
set arg1 [lindex $argv 0]
set arg2 [lindex $argv 1]
spawn openssl s_client -connect 192.168.1.181:2878  -cert /home/domo/ac/cert.pem -quiet 
expect {<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>}  
send {<Request Type="Authtoken"><User Token="xxx" /></Request>} 
send "\r"
expect "Okay" 
send {<Request Type="DeviceControl"><Control CommandID="cmd1" DUID="BC8CCD5xxxx"><Attr ID="}
send $arg1
send {" Value="}
send $arg2
send {" /></Control></Request>}
send  "\r"
expect "</Status></Update>"
exit

Set token en MAC to suit your situation. I will supply you with an openHAB implementation soon.

RemcoteWinkel commented 8 years ago

@brunofosi I purchased a Harmony as well but found out the Samsung AC IR codes are a bit to complicated for it. But we are making progress!

MrMerlino commented 8 years ago

Hello, maybe now we should just wait for the new binding. The structure dialog looks like the same of the old firmware so shouldn't be impossible the adaptation with the new openssl certificate. I'm really sorry but I don't know how to start for help now. Anyway if you need me i'm available!

RemcoteWinkel commented 8 years ago

Hi!

Of course we are all waiting for a new binding. Those interested can use my scripts in the meanwhile.

netsuso commented 8 years ago

I just wanted to confirm that I've been able to send commands to my new Samsung unit thanks to the hints provided in this thread. Other than the certificate trick, the commands seem the same as in the old units.

(Actually, I just wanted to write a couple of scripts for my own use, but I might end up using openhab if it suits my needs. The only thing that worries me is that maybe it's not the best idea to place the Samsung certificate and private key in the openhab repository, but they are required for it to work...)

thomas70 commented 8 years ago

Can someone explain how to get from AC14K_M-KeyStore.bks to ack14k_m.pfx ?

steintore commented 8 years ago

Good news! Today I've done some testing together with @RemcoteWinkel and we have found a solution to the problem. I'll try to assemble a test-version of the binding over the next couple of days. I'll let you know how the status sometime tomorrow.

Luckily there are not many changes to the binding and the communcation, as it seems to work precisely as before.

@luca-saggese Where did you find the ac14k_m.pfx-file? I need to put a link to the file so that people with this issue can download and use it, as I do not want to include it in the actual bindin itself.

MrMerlino commented 8 years ago

@luca-saggese Where did you find the ac14k_m.pfx-file? I need to put a link to the file so that people with this issue can download and use it, as I do not want to include it in the actual bindin itself.

I think is the best way....

pfx file should be created with keytool function from the bks file stored on the apk app. but i didn't understand how to convert....

luca-saggese commented 8 years ago

I've found it online, cannot rember where, i found it several weeks ago but was'nt able to use it until last week

Il giorno 15/feb/2016, alle ore 22:27, MrMerlino notifications@github.com ha scritto:

@luca-saggese Where did you find the ac14k_m.pfx-file? I need to put a link to the file so that people with this issue can download and use it, as I do not want to include it in the actual bindin itself. I think is the best way.... pfx file should be created with keytool function from the bks file stored on the apk app. but i didn't understand how to convert....

— Reply to this email directly or view it on GitHub.

RemcoteWinkel commented 8 years ago

Well, it must be contained in the .apk or derived from it as my phone is able to connect with the "in home" function.

netsuso commented 8 years ago

These are the complete steps I took yesterday, in case anyone wants to reproduce them it should be fairly easy:

keytool -importkeystore -srckeystore AC14K_M_KeyStore.bks -srcstoretype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -srcstorepass '<the_password_in_the_code>' -destkeystore ac14k_m.p12 -deststoretype PKCS12 -deststorepass 123456 -destkeypass 123456 -alias ac14k_m
openssl pkcs12 -in ac14k_m.p12 -passin pass:123456 -out ac14k_m.pem -passout pass: -nodes

I hope it helps... I didn't want to put the password or the pem certificate here as I'm not sure about the legal implications. But it should be easy for anyone to obtain it ;)

In case anyone needs more help or information, please drop me an email

netsuso commented 8 years ago

And for those not wanting to go through the full extract process (which is a bit tedious), I think it won't harm placing here a link to the certificate in base64 format: http://pastebin.com/MKTbFnK5

Just run "base64 -d < pasted.txt > cert.pem" and you are done ;)

RemcoteWinkel commented 8 years ago

A small update. I am beta testing a new binding from @steintore. Looks very promising, some minor issues left.

MrMerlino commented 8 years ago

If u need i can test too!

steintore commented 8 years ago

Here's a test-version of the new binding, there are a couple of things to notice:

There are two new optional configuration parameter, these are certificate and password, use them as this:

samsungac:Livingroom.certificate=cacert.pem samsungac:Livingroom.password=something

If you use the .pem-file described in this thread you do not need to set the password, it is just there in case we need it later (when they change the certificate again)

The certificate-parameter is the full path to the certificate-file, it should work with both the .pem-file and the .pfx-file. I do not think the .bks-file will work.

If you test it, please check the cpu and the resource use, this needs to be checked on machines that do not have a lot of extra power. This is due to me having to include two external java-libraries to handle the certificates.

If I do not get any complaints or things to fix by friday, I'll post a pull request for this. (I'll then remove the download link as well)

Thanks for testing.

download the test-binding here: http://bit.ly/20Dabae

MrMerlino commented 8 years ago

For me doesn't works i'm using openhab version 1.7.1 under windows.

This is my openhab configuration file:

samsungac:Livingroom.host=10.1.1.246 samsungac:Livingroom.mac=EDITED samsungac:Livingroom.token=d76b7f82-3d31-4635-89a6-2b0ad192866d samsungac:Livingroom.certificate=C:\Users\Administrator\Desktop\openhab\addons\cert.pem

samsungac:Livingroom.password=

Items file: Number ac_current_temp "Current temp [%.1f]" (AC) {samsungac="[Livingroom|AC_FUN_TEMPNOW]"} Switch ac_power (AC) {samsungac="[Livingroom|AC_FUN_POWER]"} Number ac_mode "Convenience mode" (AC) {samsungac="[Livingroom|AC_FUN_COMODE]"} Number ac_op_mode "Operation mode" (AC) {samsungac="[Livingroom|AC_FUN_OPMODE]"} Number ac_set_temp "Set temp [%.1f]" (AC) {samsungac="[Livingroom|AC_FUN_TEMPSET]"}

Sitemaps: Frame label="Aria Condizionata" { Text item=ac_current_temp icon="temperature" label="Temperatura [%.1f °C]" Setpoint item=ac_set_temp minValue=16 maxValue=28 step=1 icon="temperature" Switch item=ac_power icon="heating" }

On debug i just have few messages: [DEBUG] [.s.internal.SamsungAcActivator:33 ] - Samsung AC binding has been started. [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'ac_current_temp (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader. [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'ac_power (Type=SwitchItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader. [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'ac_mode (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader. [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'ac_op_mode (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader. [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item 'ac_set_temp (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader. [DEBUG] [.b.s.internal.SamsungAcBinding:59 ] - Started Samsung AC Binding [INFO ] [.b.s.internal.SamsungAcBinding:202 ] - No refresh interval configured, using default: 60000 ms [DEBUG] [.b.s.internal.SamsungAcBinding:208 ] - Configuration key is: camera.certificate

MrMerlino commented 8 years ago

I try also with a clean installation of the last version 1.8.1 with only samsung binding i try also with pfx file

steintore commented 8 years ago

@MrMerlino This line is strange:

[DEBUG] [.b.s.internal.SamsungAcBinding:208 ] - Configuration key is: camera.certificate

Why does it say "camera.certificate" in the log. Something wrong in the configuration file?

MrMerlino commented 8 years ago

Yes...i try also adding "..." Like this: samsungac:Livingroom.certificate="C:\Users\Administrator\Desktop\openhab\addons\cert.pem" But is the same....don't know how to fix!

steintore commented 8 years ago

If the cert.pem-file is in the same folder as the addon, you could try to write: samsungac:Livingroom.certificate=cert.pem

are you not getting anything else in the logs? Should print for the other configurations as well..

MrMerlino commented 8 years ago

This is my configuration; i try also with cert.pem without path!

samsungac:Livingroom.host=10.1.1.246 samsungac:Livingroom.mac=EDITED (right macaddress in configuration, with openssl works correctly) samsungac:Livingroom.token=d76b7f82-3d31-4635-89a6-2b0ad192866d samsungac:Livingroom.certificate=cert.pem

samsungac:Livingroom.password=

steintore commented 8 years ago

Ok, try running in debug-mode to se if there's some more details in the log. Another thing you can try is to adjust logging of the binding <logger name="org.openhab.binding.samsungac" level="DEBUG" />

MrMerlino commented 8 years ago

I'm so sorry because probably i'm making a big error but i didn't understand where.... I'm already trying to debugging and yet modified the log file (logback_debug.xml) adding level ="debug" as u suggested! Thanks for spending your time...

MrMerlino commented 8 years ago

@RemcoteWinkel Can u post your configuration and debug output pls? I try also redownloadwing jar and also in another computer :(

RemcoteWinkel commented 8 years ago

Sure @MrMerlino, glad to help.

Configuration:

# Host and port of the first AC to control
samsungac:Remco.host=192.168.1.181
samsungac:Remco.mac=BC8CCD54xxxx
samsungac:Remco.token=2613a007-f322-4093-a05f-49386c403177
samsungac:Remco.certificate=/home/remco/testac/ac14k_m.pfx

(Note: Linux use "/" in the path, Windows "\") Use start_debug.bat to get extra debug information in the log.

Log (relevant parts)

20:18:08.826 DEBUG o.o.b.s.i.SamsungAcActivator[:33]- Samsung AC binding has been started.
20:18:10.493 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_ct (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.499 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_p (Type=SwitchItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.501 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_m (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.505 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_om (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.507 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_st (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.510 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_d (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.519 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_w (Type=NumberItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.521 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_ac_error (Type=StringItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.524 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_add_spi (Type=SwitchItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.530 DEBUG o.o.m.i.i.GenericItemProvider[:341]- Start processing binding configuration of Item 'r_add_ac (Type=SwitchItem, State=Uninitialized)' with 'SamsungAcGenericBindingProvider' reader.
20:18:10.642 DEBUG o.o.b.s.i.SamsungAcBinding[:59]- Started Samsung AC Binding
20:18:10.656 INFO  o.o.b.s.i.SamsungAcBinding[:202]- No refresh interval configured, using default: 60000 ms
20:18:10.674 DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: Remco.certificate
20:18:10.676 DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: Remco.host
20:18:10.677 DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: Remco.mac
20:18:10.679 DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: Remco.token
20:18:10.681 DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: service.pid
20:18:10.691 INFO  o.o.c.s.AbstractActiveService[:169]- Samsung Air Conditioner service has been started
20:18:19.055 DEBUG o.o.b.s.i.SamsungAcBinding[:286]- Broken connection found for 'Remco', attempting to reconnect...
20:18:20.215 INFO  o.b.o.s.c.AirConditioner[:130]- Token has been acquired: 2613a007-f322-4093-a05f-49386c403177
20:18:24.329 DEBUG o.o.b.s.i.SamsungAcBinding[:289]- Connection to Samsung AC: [192.168.1.181:2878, MAC: BC8CCD54FE41, TOKEN: 2613a007-f322-4093-a05f-49386c403177] has succeeded
20:20:38.121 DEBUG o.o.b.s.i.SamsungAcBinding[:303]- Getting status for ac: 'Remco'
20:20:40.183 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_MACLOW
20:20:40.184 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_OPTIONCODE
20:20:40.185 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_POWER
20:20:40.186 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_p gets updated to: OFF
20:20:40.188 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_OUT_VERSION
20:20:40.189 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_INTERNET
20:20:40.190 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_MACMID
20:20:40.192 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_VENDER03
20:20:40.193 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_VENDER01
20:20:40.194 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_SETKWH
20:20:40.195 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_STARTWPS
20:20:40.196 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_VENDER02
20:20:40.198 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_DIRECTION
20:20:40.199 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_d gets updated to: 3
20:20:40.201 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_CLEAR_POWERTIME
20:20:40.203 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_USEDPOWER
20:20:40.204 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_MODEL
20:20:40.205 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_AUTOCLEAN
20:20:40.206 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_add_ac gets updated to: OFF
20:20:40.207 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_FILTER_USE_TIME
20:20:40.209 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_ENABLE
20:20:40.210 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_OPMODE
20:20:40.212 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_om gets updated to: 3
20:20:40.215 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_USEDTIME
20:20:40.217 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_OUTDOOR_TEMP
20:20:40.218 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_WINDLEVEL
20:20:40.219 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_w gets updated to: 1
20:20:40.220 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_TEMPNOW
20:20:40.222 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_ct gets updated to: 18
20:20:40.223 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_CLEAR_FILTER_ALARM
20:20:40.225 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_ERROR
20:20:40.226 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_error gets updated to: NULL
20:20:40.228 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_COOL_CAPABILITY
20:20:40.229 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_SPI
20:20:40.230 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_add_spi gets updated to: OFF
20:20:40.231 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_WIFI
20:20:40.233 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_USEDWATT
20:20:40.235 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD_APMODE_END
20:20:40.237 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_SLEEP
20:20:40.240 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_COMODE
20:20:40.243 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_m gets updated to: 0
20:20:40.250 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_FILTERTIME
20:20:40.252 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_PANEL_VERSION
20:20:40.254 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_WARM_CAPABILITY
20:20:40.257 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_FUN_TEMPSET
20:20:40.259 DEBUG o.o.b.s.i.SamsungAcBinding[:352]- r_ac_st gets updated to: 24
20:20:40.262 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_ADD2_VERSION
20:20:40.268 DEBUG o.o.b.s.i.SamsungAcBinding[:311]- Trying to find item for: Remco and cmd: AC_SG_MACHIGH
MrMerlino commented 8 years ago

Stop working here probably: DEBUG o.o.b.s.i.SamsungAcBinding[:208]- Configuration key is: Remco.certificate Could be a Windows problem?

RemcoteWinkel commented 8 years ago

Let me dust off my Windows machine and try,

MrMerlino commented 8 years ago

I'm so sorry for that but i really don't know what doesn't works! Thanks again to all!

RemcoteWinkel commented 8 years ago

Got an error too on my Windows machine. @steintore what can you make of it?

20:51:44.358 DEBUG o.o.b.s.i.SamsungAcBinding[:286]- Broken connection found for 'Remco', attempting to reconnect...
20:51:44.873 DEBUG o.o.b.s.i.SamsungAcBinding[:294]- java.lang.Exception: Could not connect using certificate: D:\testAC\ac14k_m.pfx : 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
MrMerlino commented 8 years ago

What's your logback_debug.xml configuration? i add this:

but i don't have this debug info!

RemcoteWinkel commented 8 years ago
``` %d{HH:mm:ss.SSS} %-5level %logger{30}[:%line] - %msg%n%ex{10} ${openhab.logdir:-logs}/openhab.log %d{HH:mm:ss.SSS} %-5level %logger{30}[:%line]- %msg%n%ex ${openhab.logdir:-logs}/events.log events-%d{yyyy-ww}.log.zip 30 %d{yyyy-MM-dd HH:mm:ss} - %msg%n ```
MrMerlino commented 8 years ago

Really don't understand why you have a different debug log..... Bah!

thomas70 commented 8 years ago

@RemcoteWinkel

I have the same problem on a RPI

21:15:32.785 [DEBUG] [.b.s.internal.SamsungAcBinding:294 ] - java.lang.Exception: Could not connect using certificate: /etc/openhab/configurations/cert.pem : 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

pi@raspberrypi:~ $ java -version java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

RemcoteWinkel commented 8 years ago

@MrMerlino I start openHAB from a terminal (click on windows, then run, then type cmd, then enter, then cd \Users\Administrator\Desktop\openhab then enter) with the command start_debug. (Writing it down in full, but maybe you already know all this).

@thomas70 Thanks, I think we can nail it down to a certificate path issue. Did you add the ROOTCA certificate to your ca-certs? If not, I will have to look for the procedure (no SSL expert, but soon to be I am afraid thanks to Samsung), but it comes down to extracting the self-signed certificate from the ac and then adding that to you list of trusted sources in ca-certifcates. I did that on my testing and production machines, as I remember, but never on my Windows machine.

RemcoteWinkel commented 8 years ago

Good news, @steintore and I confirmed this is the issue. A little patience now so we can work out a way to solve this issue. The more impatient amongst us can take a look at https://github.com/escline/InstallCert Performing this procedure with the first certificate from the chain produced by the ac will do the magic.

thomas70 commented 8 years ago

Thank you @RemcoteWinkel and @steintore :-)

08:28:02.841 [DEBUG] [.b.s.internal.SamsungAcBinding:289 ] - Connection to Samsung AC: [192.168.1.174:2878, MAC: BC8CCDXXXXXX, TOKEN: 3dbe5510-e09f-4ab9-bc28-9685fc7396ff] has succeeded

steintore commented 8 years ago

Great @thomas70 . Could you please post a step-by-step list to get this fixed? I'd like to post it on the wiki-page for the binding.

thomas70 commented 8 years ago

Here is what i did:

10:24:01.703 [DEBUG] [.b.s.internal.SamsungAcBinding:294 ] - java.lang.Exception: Could not connect using certificate: /etc/openhab/configurations/cert.pem : 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

sudo /etc/init.d/openhab stop

wget "https://raw.githubusercontent.com/escline/InstallCert/master/InstallCert.java"
javac InstallCert.java
java InstallCert 192.168.1.174:2878
keytool -exportcert -alias 192.168.1.174-1 -keystore jssecacerts -storepass changeit -file 192.168.1.174.cer
sudo keytool -import -keystore /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/security/cacerts -alias 192.168.1.174 -file 192.168.1.174.cer -storepass changeit

sudo /etc/init.d/openhab start

10:36:54.562 [DEBUG] [.b.s.internal.SamsungAcBinding:289 ] - Connection to Samsung AC: [192.168.1.174:2878, MAC: BC8CCDXXXXXX, TOKEN: 3dbe5510-e09f-4ab9-bc28-9685fc7396ff] has succeeded

MrMerlino commented 8 years ago

Update? thanks :)