Skip to content
pubscout

http_certificate_pinning

3.0.2, released 4 months ago by softarch.dev

Https Certificate pinning for Flutter apps.

$ flutter pub add http_certificate_pinning
Source repository

What it does

Checks equality between known SHA-1 or SHA-256 fingerprints and the target server's certificate fingerprint. It integrates with Dio via an interceptor, provides a secure http client, or can be called directly for custom implementations.

AI-written summary of version 3.0.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to prevent man-in-the-middle attacks by validating server certificate fingerprints.
  • You are using Dio or the http package and want to add certificate pinning.

Skip it when

  • You do not control or regularly update your server's SSL/TLS certificates, as pin changes will break the app.
  • You require advanced certificate validation beyond simple SHA-1/SHA-256 fingerprint matching.

Strengths

  • Provides built-in interceptors and clients for popular networking libraries like Dio and http.
  • Supports checking certificates via SHA-1 and SHA-256 fingerprints.

Weaknesses

  • Requires manual updating of certificate fingerprints in the app when server certificates rotate.
  • Limited documentation on platform-specific native setup or edge cases.

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
2

Requires adding the dependency and configuring allowed SHA fingerprints along with OpenSSL commands to extract the certificate fingerprint.

import 'package:http_certificate_pinning/http_certificate_pinning.dart';

Dio getClient(String baseUrl, List<String> allowedSHAFingerprints) {
    var dio = Dio(BaseOptions(baseUrl: baseUrl))
      ..interceptors.add(CertificatePinningInterceptor(allowedSHAFingerprints));
    return dio;
}

Alternatives

Packages that do the same job and could replace http_certificate_pinning.

  • http2

    An HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.

  • relic

    Lightweight web server framework inspired by Shelf, with typed APIs and a high‑performance native Zig adapter.

  • http_security_pinning

    SPKI SHA-256 TLS certificate pinning for Flutter with a drop-in HttpClient.

  • belatuk_http_server

    Utility classes that simplify building Dart server‑side HTTP services with HttpServer.

Works with

Packages commonly used together with http_certificate_pinning: ones it builds on, ones built on it, and its own family.