Skip to content

Commit f905cf0

Browse files
authored
Cert fix for newer Hue App versions (diyhue#932)
1 parent fe1805d commit f905cf0

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

.build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ COPY requirements.txt ./
1717
RUN apt update \
1818
&& apt install --no-install-recommends -y \
1919
curl unzip python3-minimal python3-pip python3-dev python3-setuptools gcc \
20-
openssl nmap psmisc iproute2 bluez bluetooth libcoap3-bin \
20+
openssl nmap psmisc iproute2 bluez bluetooth libcoap3-bin faketime \
2121
&& pip3 install -r requirements.txt --no-cache-dir --break-system-packages \
2222
&& apt purge -y python3-pip python3-setuptools python3-dev gcc \
2323
&& apt autoremove -y \

BridgeEmulator/genCert.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
mac=$1
33
config="${2:-/opt/hue-emulator/config}"
44
dec_serial=`python3 -c "print(int(\"$mac\".strip('\u200e'), 16))"`
5-
openssl req -new -days 3650 -config /opt/hue-emulator/openssl.conf -nodes -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve -subj "/C=NL/O=Philips Hue/CN=$mac" -keyout private.key -out public.crt -set_serial $dec_serial
5+
faketime '2017-01-01 00:00:00' openssl req -new -days 7670 -config /opt/hue-emulator/openssl.conf -nodes -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve -subj "/C=NL/O=Philips Hue/CN=$mac" -keyout private.key -out public.crt -set_serial $dec_serial
66

77
mkdir -p $config
88
touch $config/cert.pem

BridgeEmulator/install.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ generate_certificate () {
3838

3939
echo "Generating certificat for MAC $mac"
4040
echo -e "\033[33mIf this is a diyhue reinstallation process then you will need to reinstall official Hue apps from PC and phone in order to wipe old certificate.\033[0m"
41-
curl https://raw.githubusercontent.com/diyhue/diyHue/9ceed19b4211aa85a90fac9ea6d45cfeb746c9dd/BridgeEmulator/openssl.conf -o openssl.conf
4241
serial="${mac:0:2}${mac:3:2}${mac:6:2}fffe${mac:9:2}${mac:12:2}${mac:15:2}"
4342
dec_serial=`python3 -c "print(int(\"$serial\", 16))"`
44-
openssl req -new -config openssl.conf -nodes -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve -subj "/C=NL/O=Philips Hue/CN=$serial" -keyout private.key -out public.crt -set_serial $dec_serial -days 3650
43+
faketime '2017-01-01 00:00:00' openssl req -new -config openssl.conf -nodes -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve -subj "/C=NL/O=Philips Hue/CN=$serial" -keyout private.key -out public.crt -set_serial $dec_serial -days 7670
4544
if [ $? -ne 0 ] ; then
4645
echo -e "\033[31m ERROR!! Local certificate generation failed! Attempting remote server generation\033[0m"
4746
### test is server for certificate generation is reachable
@@ -98,11 +97,11 @@ esac
9897
echo -e "\033[36m Installing dependencies.\033[0m"
9998
if type apt &> /dev/null; then
10099
# Debian-based distro
101-
apt-get install -y unzip python3 python3-pip openssl bluez bluetooth libcoap2-bin
100+
apt-get install -y unzip python3 python3-pip openssl bluez bluetooth libcoap2-bin faketime
102101
elif type pacman &> /dev/null; then
103102
# Arch linux
104103
pacman -Syq --noconfirm || exit 1
105-
pacman -Sq --noconfirm unzip python3 python-pip gnu-netcat libcoap || exit 1
104+
pacman -Sq --noconfirm unzip python3 python-pip gnu-netcat libcoap faketime || exit 1
106105
else
107106
# Or assume that packages are already installed (possibly with user confirmation)?
108107
# Or check them?

BridgeEmulator/openssl.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ x509_extensions = usr_cert
1111
[ usr_cert ]
1212
basicConstraints=critical,CA:FALSE
1313
subjectKeyIdentifier=hash
14-
authorityKeyIdentifier=keyid,issuer
14+
authorityKeyIdentifier=keyid:always,issuer:always
1515
keyUsage = critical, digitalSignature, keyEncipherment
1616
extendedKeyUsage = serverAuth
1717

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ All documentation and instructions can be found over at [diyhue.readthedocs.io](
4444
- coap-client: i.e. via `apt install libcoap2-bin`
4545
- Python 3
4646
- Python modules: ws4py, requests, astral, paho-mqtt [see requirements.txt](./requirements.txt)
47+
- faketime: i.e. via `apt install faketime`
4748

4849
or
4950

0 commit comments

Comments
 (0)