SebastianOsinski / HomebridgePluginSamsungAirConditioner

Homebridge plugin for controlling Samsung Air Conditioners working on port 2878
MIT License
29 stars 18 forks source link

error #1

Closed stalkerj closed 6 years ago

stalkerj commented 6 years ago

Hello. Here is an Error that I got after step 4 (also you got a mistake there - must be "homebridge-samsung-ac-get-token <your ac's ip address>")

Here is me error:

pi@raspberrypi:~ $ homebridge-samsung-ac-get-token 10.0.1.21 IP: 10.0.1.21 Error: 1993191296:error:14082174:SSL routines:ssl3_check_cert_and_algorithm:dh key too small:../deps/openssl/openssl/ssl/s3_clnt.c:3641:

What is wrong?

SebastianOsinski commented 6 years ago

@stalkerj Thanks for noticing a typo. TBH I developed and tested whole plugin on macOS. Currently setting up raspberry pi to see if I can reproduce this error. I'll keep you posted. That's a lesson for me - always test on target platform before releasing ;)

SebastianOsinski commented 6 years ago

@stalkerj I just tested it on my Raspberry Pi and it works fine... Can you run openssl version in raspberry's terminal and check what version you have? Mine is OpenSSL 1.1.0f 25 May 2017. You can also include some other info like NodeJS version or your Raspbian version. I also did some research and it looks like AC uses too weak certificate, it can be mitigated but it's hard for me to do that as I can't reproduce that on my setup.

SebastianOsinski commented 6 years ago

@stalkerj I created temporary branch with some diagnostics added. Could you run npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue and then try homebridge-samsung-ac-get-token 10.0.1.21? It might succeed (but plugin won't as I didn't make any changes in there yet) and should display CIPHER. Please post the value of CIPHER here.

stalkerj commented 6 years ago

pi@raspberrypi:~ $ openssl version OpenSSL 1.1.0f 25 May 2017

stalkerj commented 6 years ago

pi@raspberrypi:~ $ npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue npm WARN checkPermissions Missing write access to /usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner npm WARN checkPermissions Missing write access to /usr/lib/node_modules npm ERR! path /usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner' npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner' npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in: npm ERR! /home/pi/.npm/_logs/2018-10-09T18_26_57_350Z-debug.log

SebastianOsinski commented 6 years ago

@stalkerj try it again with sudo: sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue

stalkerj commented 6 years ago

pi@raspberrypi:~ $ sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue npm ERR! code 128 npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b debug/cipher-issue git://github.com/SebastianOsinski/HomebridgePluginSamsungAirConditioner.git /root/.npm/_cacache/tmp/git-clone-64550642 npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-64550642': Permission denied npm ERR!

╭─────────────────────────────────────╮ │ │ │ Update available 5.6.0 → 6.1.0 │ │ Run npm i -g npm to update │ │ │ ╰─────────────────────────────────────╯

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-10-09T18_29_32_104Z-debug.log

stalkerj commented 6 years ago

my node version is v8.11.3

stalkerj commented 6 years ago

and I just updated npm to latest version

SebastianOsinski commented 6 years ago

Do you have Mac or maybe linux? It might be easier to do that on your PC and not RPi. I don't know why it fails to install there. I found some solution which advises to log in as root to your Pi and then running this command with sudo

stalkerj commented 6 years ago

root@raspberrypi:~# sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue /usr/bin/homebridge-samsung-ac-get-token -> /usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner/ac-get-token.js

stalkerj commented 6 years ago

I have mac but all my devices controlling by homebridge in my RPi

SebastianOsinski commented 6 years ago

Ok, I changed one more thing, you can run sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue again and then homebridge-samsung-ac-get-token 10.0.1.21. If this won't give as an answer, then I'm out of ideas.

stalkerj commented 6 years ago

root@raspberrypi:~# sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue /usr/bin/homebridge-samsung-ac-get-token -> /usr/lib/node_modules/homebridge-plugin-samsung-air-conditioner/ac-get-token.js

SebastianOsinski commented 6 years ago

I'm out of ideas TBH. I dig into OpenSSL to find source of this error and it looks like your air conditioner uses some obsolete cipher suites which were removed in OpenSSL 1.1.0. Mine uses AES-256. I don't know why yours is different. From what year is your device? Also, do you sometimes use SmartAirConditioner app from Samsung to control your device? I read somewhere that Samsung pushed some silent update to their ACs which changed something with ciphers

stalkerj commented 6 years ago

Yes I use their app because I have no other possibility to control it from my phone. Here is models that I have AR09HSSFRWKNER and AR12HSSFRWKNER both are 2014

SebastianOsinski commented 6 years ago

@stalkerj I just found some thread on the Internet about your issue, it contains a possible solution. I’ll apply it tomorrow and ping you to test it

jadomski commented 6 years ago

I think I've got the same issue:

[Error: 3065644160:error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small:../deps/openssl/openssl/ssl/statem/statem_clnt.c:1472: ]

SebastianOsinski commented 6 years ago

@stalkerj @iJaffa Ok, so there is a solution according to https://community.home-assistant.io/t/samsung-ac/11747. I updated my test branch, please run sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#debug/cipher-issue as root and then homebridge-samsung-ac-get-token <your-ac-ip-address> and post what happens

stalkerj commented 6 years ago

I’m sorry, but i’m on vacation till 24.10, will check only after came back

jadomski commented 6 years ago

Looks like that worked, @SebastianOsinski! Here's the output I got (masked token):

$ homebridge-samsung-ac-get-token 192.168.1.28
IP:  192.168.1.28
Cipher test
CIPHER:  { name: 'AES256-SHA', version: 'TLSv1/SSLv3' }
Power on the device within the next 30 seconds
Device token:  aaaaaaaa-bbbb-cccc-eeee-ffffffffffff
SebastianOsinski commented 6 years ago

@iJaffa great! I fixed both token tool and plugin to work with your AC. Please check it: sudo npm install -g github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#fix/key-too-small. If it works, I'll publish new update. Also please post your AC model number, so I can add it to compatibility list :)

jadomski commented 6 years ago

It works! My model number is AR24FSSSBWKN.

My unit shows this in the Samsung AC app too, if it helps: Smart Module Ver 01538A130723 InDoor Unit Ver 130814 OutDoor Unit Ver 130709

SebastianOsinski commented 6 years ago

@iJaffa Great, I just published new version 1.0.2. You can install it with normal command sudo npm install -g homebridge-plugin-samsung-air-conditioner :) Thank your for your help with debugging this issue