Search packages, repositories and app categories

GitHub repositorydiefferson/http_certificate_pinning

http_certificate_pinning

Https Certificate pinning for Flutter

http_certificate_pinning project cover
Stars
103
Forks
110
Last push (UTC)
Jul 21, 2026
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Http Certificate Pinning

Https Certificate pinning for Flutter

This project is based on ssl_pinning_plugin

Any help is appreciated! Comment, suggestions, issues, PR's!

Getting Started

In your flutter or dart project add the dependency:

dependencies:
  ...
  http_certificate_pinning: 3.0.1

Get Certificate FingerPrint

To get SHA256 certificate fingerprint run in console:

openssl x509 -noout -fingerprint -sha256 -inform pem -in [certificate-file.crt]

The Result is like:

'59:58:57:5A:5B:5C:5D:59:58:57:5A:5B:5C:5D:59:58:57:5A:5B:5C:5D:59:58:57:5A:5B:5C:5D:59:58:57:5A:5B:5C:5D'

Usage example

Using Dio
import 'package:http_certificate_pinning/http_certificate_pinning.dart';
  
  // Add CertificatePinningInterceptor in dio Client
  Dio getClient(String baseUrl, List<String> allowedSHAFingerprints) {
      var dio = Dio(BaseOptions(baseUrl: baseUrl))
        ..interceptors.add(CertificatePinningInterceptor(allowedSHAFingerprints));
      return dio;
  }

  myRepositoryMethod() {
    dio.get("myurl.com");
  }
Using Http
import 'package:http_certificate_pinning/secure_http_client.dart';
  
  // Uses SecureHttpClient to make requests
  SecureHttpClient getClient(List<String> allowedSHAFingerprints) {
      final secureClient = SecureHttpClient.build(certificateSHA256Fingerprints);
      return secureClient;
  }

  myRepositoryMethod() {
    secureClient.get("myurl.com");
  }
Other Client
import 'package:http_certificate_pinning/http_certificate_pinning.dart';
  
Future myCustomImplementation(String url, Map<String,String> headers, List<String> allowedSHAFingerprints) async {
  try {
    final secure = await HttpCertificatePinning.check(
      serverURL: url,
      headerHttp: headers,
      sha: SHA.SHA256,
      allowedSHAFingerprints: allowedSHAFingerprints,
      timeout : 50
    );

    return secure.contains("CONNECTION_SECURE");
  } catch(e) {
    return false;
  }
}
Diefferson Santos GitHub avatar
GitHub author

Diefferson Santos ↗

Mobile Engineer

@Noodle-CxBrasil
LanguagesDartSwiftKotlinRubyObjective-C

Packages published by this repository

Dependencies used

Dependency list 5 items

  • dio>=4.0.6 <6.0.0
  • flutter{"sdk":"flutter"}
  • http^1.3.0
  • flutter_lintsDevelopment^5.0.0
  • flutter_testDevelopment{"sdk":"flutter"}

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗