InkApplications / Shade

💡 Unofficial SDK for the Philips Hue API written for Kotlin Multiplatform.
https://shade.lighting
MIT License
65 stars 4 forks source link

Override OkHttp Trustmanager for insecure connections. #130

Closed ReneeVandervelde closed 3 months ago

ReneeVandervelde commented 3 months ago

The InsecureTrustManager in OkHttp attempts to do an ip hostname lookup before attempting the SSL handshake, despite the fact that this handshake will not be validated. This is in order to restrict the insecure connection configuration to only that hostname. This causes a significant delay when trying to resolve a local IP in the first request.

The HTTP Client used in Shade's API calls is already restricted to the specific IP that is configured, so this hostname validation is unecessary.

This fix resolves the performance issue by overriding the trustmanager on insecure configurations to be fully ignored.

This should resolve some of the performance issues seen in #122