Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Certificate has expired error message ( cert_has_expired ) #88

Closed quadhammer closed 1 year ago

quadhammer commented 2 years ago

I've been using this plug-in very successfully with the home assistant node red plug-in inside a virtual machine (Oracle VM Virtualbox), but since the last upgrade to 0.2.9, (that I've noticed anyway),it refuses to connect.

I used to just use my home assistant IP, port 8443, ticked SSL, and put in my version 6 password credentials. I've tried reinstalling the unifi plug-in, and deleting any folders inside node red afterwards.

I've tried upgrading to version 7 of the Unifi software 7.2.94, and I can login as usual on both localhost: 8443, or my local computer's IP:8443, but for some reason I can't login with the node red plug-in anymore.

it doesn't matter whether I pick Unifi OS, or untick it.

Screenshot 2022-10-04 16 48 56

Thanks for any help.

Isaksson commented 2 years ago

Hello. If you untick both Unifi OS and SSL Verification, what is the result then?

quadhammer commented 2 years ago

hello,

It's the same error message if I untick both boxes.

Isaksson commented 2 years ago

I have make some tests now agains a Unifi Controller that has an expired certificate and I could reproduce your error, well its not an error but if SSL Verification is selected then it will produce that message, but when I uncheck then its working as it should. Please verify your settings again.

quadhammer commented 2 years ago

OK, after a reboot, and a reinstall, I'm now getting: ECONNREFUSED

Disabling the windows firewall made no difference.

Screenshot 2022-10-08 16 34 35

Isaksson commented 2 years ago

That means that the IP or port is wrong. If your controller is Unifi OS then you should select the box Unifi OS and the port 443 if your controller is not Unifi OS then unselect that box and use port 8443

This is standard values, if you have changed them then you have to use your settings.

quadhammer commented 2 years ago

UniFi Network Application 7.2.94 is what I'm using. It's on port 8443.

https://localhost:8443/manage/default/dashboard brings it up, or https://127.0.0.1:8443/manage/default/dashboard

in the past I've put my local home assistant IP in there, and it's worked, but not now.

Untitled

Is what the Oracle VM Virtualbox settings look like. Perhaps it's not passing through the bridge? But it used to, and nothing's changed settings wise there.

quadhammer commented 2 years ago
WARN view - Successfully authenticated SSO user user@hotmail.com, but it does not match any local admin I found this in the Unifi logs. Perhaps it's related?
Isaksson commented 2 years ago

Does it make any difference if you use the actual IP address of the server, not localhost or 127.0.0.1?

quadhammer commented 1 year ago

Screenshot 2022-10-09 14 24 55

Yes, it does make a difference. if I use the home assistant IP ( which used to work), I get connection refused. The same with localhost and 127.0.0.1.

But if I use the actual server IP, in other words the local IP of my computer, e.g. 192.168.x.x then I get 'ERR_BAD_REQUEST'.

Also, if I tick the SSL box, then the certificate expired error comes back, as is to be expected by the look.

Nokomis449 commented 1 year ago

Make sure the time and time zone settings on the controller and the machine (VirtualBox) running Node RED are current. If the settings are different, I.E. one machine didn't have the time set by NTP and defaulted to 1970, the certificate is considered invalid because its valid timeframe is 50+ years in the future. Also, I've had certificate failures because one machine is ahead of the other by a few hours due to different time/time zone settings, and the certificate won't allow a connection from the future (or from the past).
To eliminate a firewall problem make sure you can ping from each device to the other. ECONNREFUSED usually means an incorrect port was specified, or the port is already in use. It sounds like you've got several things running on the same machine; maybe something else is using the same port.

quadhammer commented 1 year ago

They are both set to UTC, and NTP is set to Auto on the Unifi server, and Windows time server is set to the same UTC, and has been synchronised.

If I use a ping node in node red, and put in my local IP, it pings it with no problem.

I do have the Unifi integration (https://www.home-assistant.io/integrations/unifi) running in Home Assistant, so that seemed like a really good idea. But alas, even if I disable the add-on in Home Assistant, the same error persists.

quadhammer commented 1 year ago

Screenshot 2022-10-10 14 46 29

Finally got it working by adding a new admin account, which I tried before, but must not have had the right IP, or both boxes unticked. It needed my local IP of the Unifi server.

Thanks to you both for your patience and help.

Oh, also, the payload has changed so https://discourse.nodered.org/t/function-node-error-typeerror-msg-payload-0-filter-is-not-a-function/67390/5 helped me out. Things like a device's temperature went from payload[0].general_temperature to payload[1].general_temperature, etc.

Screenshot 2022-10-10 15 32 43