pinnedClient function
An http.Client that accepts the server only when its certificate's SHA-256 matches pin — for self-signed
installations (TOFU) and for CA-signed certificates (checked on every response).
Implementation
http.Client pinnedClient(String pin) {
final inner = HttpClient()
..badCertificateCallback = (cert, host, port) =>
fingerprintMatches(sha256.convert(cert.der).toString(), pin);
return _PinnedClient(IOClient(inner), inner, pin);
}