secure_pinning_http 0.0.2 copy "secure_pinning_http: ^0.0.2" to clipboard
secure_pinning_http: ^0.0.2 copied to clipboard

package:http integration for secure_pinning — a BaseClient wrapper with full verb + streaming support, built on secure_pinning's pure-Dart pinning engine.

example/lib/main.dart

import 'dart:io';

import 'package:secure_pinning/secure_pinning.dart' show SecurePinningException;
import 'package:secure_pinning_http/secure_pinning_http.dart';

Future<void> main() async {
  final client = SecurePinningHttpClient.forHost(
    'api.example.com',
    // Replace with your own host's real SPKI pins — compute them with:
    //   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 -hex \
    //     | awk '{print $NF}'
    // Always include a backup pin so a future key rotation doesn't brick
    // the app.
    pins: ['hex-spki-hash-1', 'hex-spki-hash-2'],
  );

  try {
    final response = await client.get(Uri.https('api.example.com', '/'));
    stdout.writeln(
      'HTTP ${response.statusCode} — ${response.bodyBytes.length} bytes',
    );
  } on SecurePinningException catch (error) {
    stdout.writeln('Pinning failed: $error');
  } finally {
    client.close();
  }
}
0
likes
160
points
118
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

package:http integration for secure_pinning — a BaseClient wrapper with full verb + streaming support, built on secure_pinning's pure-Dart pinning engine.

Repository (GitHub)
View/report issues
Contributing

Topics

#security #networking #certificate-pinning #http

License

Apache-2.0 (license)

Dependencies

flutter, http, secure_pinning

More

Packages that depend on secure_pinning_http