Home Bridge Home Assistant Plugin SSL

Just added my SSL certificates to Home Assistant. Everything seams to be working great now.

With one exception HomeBridge now can’t talk to HomeAssistant i updated my HomeBridge config to reflect the change in https trying both my local IP and my DDNS address.

I am receiving this error in HomeBridge

[HomeAssistant] Failed getting devices: Error: unable to verify the first certificate. Retrying…

Is this a limitation to the current HomeBridge plugin? Or is there a fix? Has anybody overcome this problem?

Do you get any SSL warnings when viewing Home Assistant in a browser? Are you using a self-signed certificate, Lets Encrypt certificate, or some other provider?

The error seems like it’s having problems verifying certificate, which could happen for self-signed for sure.

I get zero warnings when viewing in browser. I’m using a cert issued by Comodo to my DDNS address.

Problem Solved

If anybody else runs into this problem it was solved by adding the contents from the .ca-bundled file to the bottom of the crt file received from Comodo.

Thanks for the reply @technicalpickles

Hi @jamieb

I’m wondering what you mean with the .ca-bundled file. I have my SSL running by Let’s Encrypt. do you have any clue how i can solve it in this SSL setup?

@technicalpickles: Im not using a docker. So that would not work for me unfortunately.

Thanks,

I run into the same error.

I have a valid certificate signed to my DNS address. This works great with HA.

But in Homebridge I see this error, I think because its a local https address.

[HomeAssistant] Failed getting devices: Error: unable to verify the first certificate. Retrying...

This is the official solution but I’m not sure what to do. I start homebridge with systemd
Pls help

Using with self signed SSL certificates
If you have set up SSL using a self signed certificate, you will need to start Homebridge after running export NODE_TLS_REJECT_UNAUTHORIZED=0 to allow bypassing the Node.js certificate checks.

This is my homebridge config. With http everything works fine.

"platform": "HomeAssistant",
      "name": "HomeAssistant",
      "host": "http://192.168.2.25:8123",
      "password": "password",
      "supported_types": ["binary_sensor", "cover", "fan", "input_boolean", "light", "lock", "scene", "sensor", "switch"]
1 Like

Have you tried setting host as your DNS address?

Yes,
I tried this without luck. And I tested this with a Let Encrypt Certificate, too. With same result.

  "platform": "HomeAssistant",
  "name": "HomeAssistant",
  "host": "https://mydnsadress:8123",
  "password": "mypassword",
  "supported_types": ["binary_sensor", "cover", "fan", "input_boolean", "light", "lock", "scene", "sensor", "switch"]

With the same error message:

Nov 16 11:58:25 raspberrypi homebridge[482]: [11/16/2016, 11:58:25 AM] [HomeAssistant] Failed getting devices: Error: unable to verify the first certificate. Retrying...

Do I need to put my certificate on the Homebridge Pi, too?
Actually I want to use my local address, so I’m not dependent from my IPS, DNS server or expired certificates.

I’m sorry, it still not working…

Today I installed Homebridge on the same Pi as HA, in hope to bypass that stupid SSL verification.
But no luck.

Why the hell does homebridge need this certificate, if HA is running on the same machine? I dont get it.

Ok,

now I can start homebridge with https when I start manually as “pi”

But with systemd Service I cant get to work. I added the export NODE_TLS_REJECT_UNAUTHORIZED=0 to the homebridge.server but no luck.

WHY the hell does export NODE_TLS_REJECT_UNAUTHORIZED=0 not work when I start systemd?

[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target

[Service]
Type=simple
User=pi
EnvironmentFile=/etc/default/homebridge
ExecStartPre=export NODE_TLS_REJECT_UNAUTHORIZED=0
ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
TimeoutStartSec=30

[Install]
WantedBy=multi-user.target

Edit:
Ok I find out that export NODE_TLS_REJECT_UNAUTHORIZED=0 is not Executable via ExecStart because its no absolut path

Edit2:
Still not working if I execute export NODE_TLS_REJECT_UNAUTHORIZED=0 manually and then restart the service

Now I created a script to execute export NODE_TLS_REJECT_UNAUTHORIZED=0

#!/bin/bash
# My first script

export NODE_TLS_REJECT_UNAUTHORIZED=0

And started this script with the homebridge.service systemd

[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target

[Service]
Type=simple
User=pi
EnvironmentFile=/etc/default/homebridge
TimeoutStartSec=30
ExecStartPre=/home/pi/disablessl
ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

The command seems to be executed if I start homebridge.service but sill no luck with bypassing ssl :cry:
I am despairing.

● homebridge.service - Node.js HomeKit Server
   Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
   Active: active (running) since Thu 2016-11-24 01:01:10 UTC; 11s ago
  Process: 2320 ExecStartPre=/home/pi/disablessl (code=exited, status=0/SUCCESS)
 Main PID: 2324 (homebridge)
   CGroup: /system.slice/homebridge.service
           └─2324 homebridge

Nov 24 01:01:15 raspberrypi homebridge[2324]: Failed to find plugin to handle accessory Dash Black
Nov 24 01:01:15 raspberrypi homebridge[2324]: [11/24/2016, 1:01:15 AM] [Wohnzimmer Dimmer] WebSocket connection established!
Nov 24 01:01:15 raspberrypi homebridge[2324]: [11/24/2016, 1:01:15 AM] [Wohnzimmer Dimmer] Requesting initial states...
Nov 24 01:01:15 raspberrypi homebridge[2324]: [11/24/2016, 1:01:15 AM] [Wohnzimmer Dimmer] Updated internal state to "off"
Nov 24 01:01:15 raspberrypi homebridge[2324]: [11/24/2016, 1:01:15 AM] [Wohnzimmer Dimmer] Updated internal dim level to 15
Nov 24 01:01:16 raspberrypi homebridge[2324]: [11/24/2016, 1:01:16 AM] [HomeAssistant] Failed getting devices: Error: self signed certificate. Retrying...

OK found a nice and easy solution.

I simply modified the homebridge executable set up file .

This file is located here:

/usr/lib/node_modules/homebridge/bin

Just added the command: process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Then the file look like this:

#!/usr/bin/env node

//
// This executable sets up the environment and runs the HomeBridge CLI.
//

'use strict';

process.title = 'homebridge';

// Find the HomeBridge lib
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

// Run HomeBridge
require(lib + '/cli')();

Now restart homebridge service. And the ssl errors are gone.

NOTE: THIS DISABLES ALL KINDS OF SECURITY CHECKS

I think everything is local if I put in the local home Assistant IP in config.json, so I hope this is not a big deal.

I dont know if this is the right way but this works for me and works this autostart and systemd service.

1 Like

Following your instructions and still can’t solve it. Running it in debug mode shows Client connection closed, HTTP Connection was closed, HTTP Server was closed when Homebridge attempts to communicate with HomeAssistant.

Hi,

what is the error message when you start the homebridge service?

sudo systemctl status homebridge -l

Nov 29 09:18:36 raspberrypi homebridge[4034]: [11/29/2016, 9:18:36 AM] [HomeAssistant] Fetching HomeAssistant devices.
Nov 29 09:18:37 raspberrypi homebridge[4034]: [11/29/2016, 9:18:37 AM] [HomeAssistant] Failed getting devices: Error: connect ECONNREFUSED 127.0.0.1:8123. Retrying…
Nov 29 09:18:42 raspberrypi homebridge[4034]: [11/29/2016, 9:18:42 AM] [HomeAssistant] Fetching HomeAssistant devices.
Nov 29 09:18:42 raspberrypi homebridge[4034]: [11/29/2016, 9:18:42 AM] [HomeAssistant] Failed getting devices: Error: connect ECONNREFUSED 127.0.0.1:8123. Retrying…
Nov 29 09:18:47 raspberrypi homebridge[4034]: [11/29/2016, 9:18:47 AM] [HomeAssistant] Fetching HomeAssistant devices.
Nov 29 09:18:47 raspberrypi homebridge[4034]: [11/29/2016, 9:18:47 AM] [HomeAssistant] Failed getting devices: Error: connect ECONNREFUSED 127.0.0.1:8123. Retrying…
Nov 29 09:18:52 raspberrypi homebridge[4034]: [11/29/2016, 9:18:52 AM] [HomeAssistant] Fetching HomeAssistant devices.
Nov 29 09:18:52 raspberrypi homebridge[4034]: [11/29/2016, 9:18:52 AM] [HomeAssistant] Failed getting devices: Error: connect ECONNREFUSED 127.0.0.1:8123. Retrying…
Nov 29 09:18:57 raspberrypi homebridge[4034]: [11/29/2016, 9:18:57 AM] [HomeAssistant] Fetching HomeAssistant devices.
Nov 29 09:18:57 raspberrypi homebridge[4034]: [11/29/2016, 9:18:57 AM] [HomeAssistant] Failed getting devices: Error: connect ECONNREFUSED 127.0.0.1:8123. Retrying…

Running https on port 8123

Also tried using it with actual dns-name for the ssl instead of 127.0.0.1, same error.

Hm, its not the SSL error I had.
Does this work without https?

Yes, as long as home-automation ssl is disabled.

I did this too in order to get homebridge to work, but it seems like a hack!
@robbiet480 - is there a better way to get homebridge-homeassistant working with self-signed SSL (Let’s Encrypt)? and could you update the GitHub README so it says where to put the environment variable for systemd autostart scripts?

Thanks!

From: GitHub - home-assistant/homebridge-homeassistant: DEPRECATED in favor of native HomeKit support. -  Homebridge plugin for Home Assistant

Using with self signed SSL certificates

If you have set up SSL using a self signed certificate, you will need to to set verify_ssl to false in your config.json file to allow bypassing the Node.js certificate checks.