Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hue] Added configuration for port #4728

Merged
merged 3 commits into from
Feb 9, 2019

Conversation

cweitkamp
Copy link
Contributor

@cweitkamp cweitkamp commented Jan 27, 2019

  • Added configuration for port

Continues eclipse-archived/smarthome#6854

Signed-off-by: Christoph Weitkamp [email protected]

@cweitkamp cweitkamp added the work in progress A PR that is not yet ready to be merged label Jan 27, 2019
@cweitkamp cweitkamp requested a review from lolodomo as a code owner January 27, 2019 11:59
@cweitkamp
Copy link
Contributor Author

cweitkamp commented Jan 27, 2019

@martinvw Can you give me a hand on the TlsTrustManager implementations? For now I tries to follow the approach of the unifi binding including a "trust all" manager. Thanks.

The Philips Hue certificate looks like this - but I do not know if it is sufficient because the idea behind this PR is to allow the Hue binding to connect to similar Hue APIs like deCONZ too.

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 6624557528005837 (0x1788fffe403ccd)
    Signature Algorithm: ecdsa-with-SHA256
        Issuer: C = NL, O = Philips Hue, CN = 001788fffe403ccd
        Validity
            Not Before: Jan  1 00:00:00 2017 GMT
            Not After : Jan  1 00:00:00 2038 GMT
        Subject: C = NL, O = Philips Hue, CN = 001788fffe403ccd
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub:
                    04:64:1f:2f:c1:10:62:bf:fc:f1:aa:9d:41:57:e8:
                    46:db:d1:49:9d:f0:6c:02:cf:cf:70:9e:ec:2f:9e:
                    d4:e3:e7:ce:81:c4:20:a3:f2:2a:af:75:3a:be:c7:
                    7b:58:f4:4a:f8:71:e8:3b:24:a1:2a:19:52:1d:91:
                    4b:01:41:14:e2
                ASN1 OID: prime256v1
                NIST CURVE: P-256
        X509v3 extensions:
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Key Identifier: 
                38:C8:28:A2:62:A4:AC:2A:53:83:21:4D:EF:67:2D:D3:68:EE:C5:AB
            X509v3 Authority Key Identifier: 
                keyid:38:C8:28:A2:62:A4:AC:2A:53:83:21:4D:EF:67:2D:D3:68:EE:C5:AB
                DirName:/C=NL/O=Philips Hue/CN=001788fffe403ccd
                serial:17:88:FF:FE:40:3C:CD

            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication
    Signature Algorithm: ecdsa-with-SHA256
         30:46:02:21:00:e4:f8:51:c4:84:80:a6:c6:4a:95:38:b2:f2:
         e3:e4:79:56:b4:b0:32:6e:27:e3:56:61:84:c5:4b:f4:85:48:
         3a:02:21:00:ec:f3:07:d5:f7:53:8a:90:83:11:ba:5e:e0:e5:
         d3:89:de:4e:8e:d4:95:7c:0b:ad:e1:a6:48:17:06:d4:8d:40

Current state is that HTTPS is not working because of this exception:

org.openhab.binding.hue.internal.exceptions.UnauthorizedException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
	at org.openhab.binding.hue.internal.HueBridge.authenticate(HueBridge.java:833) ~[232:org.openhab.binding.hue:2.5.0.201901271145]
	at org.openhab.binding.hue.internal.handler.HueBridgeHandler.onNotAuthenticated(HueBridgeHandler.java:495) [232:org.openhab.binding.hue:2.5.0.201901271145]
	at org.openhab.binding.hue.internal.handler.HueBridgeHandler$PollingRunnable.run(HueBridgeHandler.java:106) [232:org.openhab.binding.hue:2.5.0.201901271145]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

@@ -534,6 +535,7 @@ private void updateBridgeThingConfiguration(String userName) {
}

private void handleAuthenticationFailure(Exception ex, String userName) {
logger.debug("{}", ex);
Copy link
Contributor Author

@cweitkamp cweitkamp Jan 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed after we found a solution for the occurring exception.

@davidgraeff
Copy link
Member

Before we run into merge conflicts at some point, can we merge this? At least the port fix looks good and https needs further tests, I agree. But better having that in the main tree than rotting, I guess?

@cweitkamp
Copy link
Contributor Author

I thought about splitting this up into two separate PRs. One for the port and one for the HTTPS connection. I'll be the nicest way.

@cweitkamp cweitkamp removed the request for review from lolodomo February 7, 2019 06:53
@cweitkamp cweitkamp force-pushed the bugfix-hue-port-and-protocol branch from 7597286 to 472dbd5 Compare February 7, 2019 07:06
@cweitkamp
Copy link
Contributor Author

cweitkamp commented Feb 7, 2019

@davidgraeff I removed all HTTPS related changes which were visible for the user and obsolete code.

@cweitkamp cweitkamp changed the title [hue][WIP] Added configuration for port and protocol [hue][WIP] Added configuration for port Feb 7, 2019
@cweitkamp cweitkamp changed the title [hue][WIP] Added configuration for port [hue] Added configuration for port Feb 7, 2019
@cweitkamp cweitkamp removed the work in progress A PR that is not yet ready to be merged label Feb 7, 2019
try {
URI uri = new URI(protocol, null, ip, port, path.isEmpty() ? basePath : basePath + "/" + path, null, null);
return uri.toString();
} catch (URISyntaxException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do some logging here? Its unlikely that the url is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will. And I will do a second change: I will move the creation of the URI into the constructor. It is sufficient to resolve it once and not every time we want to connect to the Hue API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. But let me test it for at least one day before we merge.

Signed-off-by: Christoph Weitkamp <[email protected]>
@cweitkamp cweitkamp force-pushed the bugfix-hue-port-and-protocol branch from 91984bb to a2ad04e Compare February 7, 2019 19:36
@cweitkamp
Copy link
Contributor Author

But let me test it for at least one day before we merge.

It looks fine. Works smoothly without unexpected errors. I will give it a go.

@davidgraeff
Copy link
Member

I'll merge it in then. The hue binding is really causing havoc on my system because of it constantly forgetting the port at the moment (and colliding with hue emulation therefore).

@davidgraeff davidgraeff merged commit 103300b into openhab:master Feb 9, 2019
@cweitkamp cweitkamp deleted the bugfix-hue-port-and-protocol branch February 9, 2019 14:25
@wborn wborn added this to the 2.5 milestone Feb 28, 2019
jannegpriv pushed a commit to jannegpriv/openhab-addons that referenced this pull request Mar 3, 2019
* Added configuration for port and protocol

Signed-off-by: Christoph Weitkamp <[email protected]>
Pshatsillo pushed a commit to Pshatsillo/openhab-addons that referenced this pull request Jun 19, 2019
* Added configuration for port and protocol

Signed-off-by: Christoph Weitkamp <[email protected]>
Signed-off-by: Pshatsillo <[email protected]>
ne0h pushed a commit to ne0h/openhab-addons that referenced this pull request Sep 15, 2019
* Added configuration for port and protocol

Signed-off-by: Christoph Weitkamp <[email protected]>
Signed-off-by: Maximilian Hess <[email protected]>
@cweitkamp cweitkamp added the enhancement An enhancement or new feature for an existing add-on label Dec 14, 2019
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants