Smart Dev Pinning Plugin

This plugin creates a secure native TLS connection to execute HTTP requests with certificate pinning.

Requirements

  • Flutter 3.3.0 or higher
  • Dart SDK 3.7.2 or higher
  • Compatible with Android and iOS

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  smart_dev_pinning_plugin: ^1.0.0

Then run:

flutter pub get

How to use

Generate certificate hash

In order to use the client, it is necessary to generate an endpoint certificate hash.

Using OpenSSL

openssl s_client -connect <HOST>:443 -servername <HOST> </dev/null 2>/dev/null \
  | openssl x509 -pubkey -noout \
  | openssl pkey -pubin -outform DER \
  | openssl dgst -sha256 -binary \
  | openssl base64

Use the Client

final client = SecureClient();
final requestResponse = await client.httpRequest(
  certificateHash: "Mh7ufr6Yepdwv4IGnMFCJcVG9P0YeIqzaMr+euJo0/U=",
  method: 'GET',
  url: 'https://jsonplaceholder.typicode.com/posts/1',
  headers: {'Content-type': 'application/json; charset=UTF-8'},
);
print(requestResponse);

Example

See the example/ directory for a complete Flutter app using this plugin.

Platform Support

  • Android
  • iOS

License

See LICENSE for details.