Impossible to use HTTPS with server on local network (IoT device) that has an intermediate certificate #59948
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
library-_http
triage-automation
See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
We want to connect to our IoT device that is on the local network with HTTPS. It has a leaf certificate and an intermediate certificate. The latter is signed by our root certificate. The CN of the leaf is the id of the device. Dart's
HttpClient
with the root set viaSecurityContext.setTrustedCertificatesBytes
cannot connect to the device, as the hostname we connect to (an IP) does not match the CN (the device's id). We have not control over the hostname on a local network, butHttpClient
doesn't seem to offer a way to customise checking of the common name.Using
HttpClient.badCertificateCallback
doesn't work either as it is only called with the intermediate certificate.Related issues:
#49088
#39425
Sample code below. It can use used with a server on the local network using the attached certificates and key.
Actual
With the
badCertificateCallback
commented out, the request fails (as it should). With the callback, the output will show it is called with the intermediate certificate.Expected
Either the intermediate certificate should be checked by Dart and the callback called with the leaf certificate (or perhaps the whole chain).
Or there should be some mechanism to modify checking of the common name.
cert-chain-and-key.zip
The text was updated successfully, but these errors were encountered: