ssl_pinning_plugin 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new43

ssl_pinning_plugin

Plugin for check SSL Pinning on request HTTP.

Checks the equality between the known SHA-1 fingerprint and the SHA-1 of the target server.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Check

###Params

  • serveurUrl : String
  • headerHttp : Map<String, String>
  • allowedSHA1Fingerprint : List<String>
  • timeout : int

###Usage :

await SslPinningPlugin.check(serverURL: url, headerHttp : new Map(), allowedSHA1Fingerprint: new List<String>, timeout : 50);

###Return :

  • On success, return String "CONNECTION_SECURE"
  • On error, return String "CONNECTION_INSECURE"

If an exception, return the stacktrace on String value.

[1.0.0] - 29/05/2018

  • Checks the equality between the known SHA-1 fingerprint and the SHA-1 of the target server.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ssl_pinning_plugin/ssl_pinning_plugin.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _PiningSslData {
  String serverURL = '';
  Map<String, String> headerHttp = new Map();
  String allowedSHA1Fingerprint = '';
  int timeout = 0;
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
  _PiningSslData _data = new _PiningSslData();
  BuildContext scaffoldContext;

  @override
  initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  check(String url, String fingerprint, Map<String, String> headerHttp, int timeout) async {

    List<String> allowedShA1FingerprintList = new List();
    allowedShA1FingerprintList.add(fingerprint);

    try {
      // Platform messages may fail, so we use a try/catch PlatformException.
      String checkMsg = await SslPinningPlugin.check(serverURL: url,
          headerHttp: headerHttp,
          allowedSHA1Fingerprint: allowedShA1FingerprintList,
          timeout: timeout);

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted)
        return;

      Scaffold.of(scaffoldContext).showSnackBar(
        new SnackBar(
          content: new Text(checkMsg),
          duration: Duration(seconds: 1),
          backgroundColor: Colors.green,
        ),

      );
    }catch (e){
      Scaffold.of(scaffoldContext).showSnackBar(
        new SnackBar(
          content: new Text(e.toString()),
          duration: Duration(seconds: 1),
          backgroundColor: Colors.red,
        ),

      );
    }

  }

  void submit() {
    // First validate form.
    if (_formKey.currentState.validate()) {
      _formKey.currentState.save(); // Save our form now.

      this.check(_data.serverURL, _data.allowedSHA1Fingerprint, _data.headerHttp, _data.timeout);
    }
  }

  @override
  Widget build(BuildContext context) {
    this.scaffoldContext = context;
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Ssl Pinning Plugin'),
        ),
        body:
          new Builder(builder: (BuildContext context) {
            this.scaffoldContext = context;
            return new Container(
              padding: new EdgeInsets.all(20.0),
              child: new Form(
                key: this._formKey,
                child: new ListView(
                children: <Widget>[
                  new TextFormField(
                    keyboardType: TextInputType.url,
                    decoration: new InputDecoration(
                      hintText: 'https://yourdomain.com',
                      labelText: 'URL'
                    ),
                    validator: (value) {
                      if (value.isEmpty) {
                        return 'Please enter some url';
                      }
                    },
                    onSaved: (String value) {
                      this._data.serverURL = value;
                    }
                  ),
                  new TextFormField(
                    keyboardType: TextInputType.text,
                    decoration: new InputDecoration(
                       hintText: 'OO OO OO OO OO OO OO OO OO OO',
                       labelText: 'Fingerprint'
                    ),
                    validator: (value) {
                      if (value.isEmpty) {
                        return 'Please enter some fingerprint';
                      }
                    },
                    onSaved: (String value) {
                      this._data.allowedSHA1Fingerprint = value;
                    }
                  ),
                  new TextFormField(
                      keyboardType: TextInputType.number,
                      initialValue: '60',
                      decoration: new InputDecoration(
                          hintText: '60',
                          labelText: 'Timeout'
                      ),
                      validator: (value) {
                        if (value.isEmpty) {
                          return 'Please enter some timeout';
                        }
                      },
                      onSaved: (String value) {
                        this._data.timeout = int.parse(value);
                      }
                  ),
                  new Container(
                    child: new RaisedButton(
                      child: new Text(
                        'Check',
                        style: new TextStyle(
                          color: Colors.white
                        ),
                      ),
                      onPressed: () => submit(),
                      color: Colors.blue,
                    ),
                    margin: new EdgeInsets.only(
                      top: 20.0
                    ),
                  )
                ],
              ),
            )
          );
        })
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ssl_pinning_plugin: "^0.0.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:ssl_pinning_plugin/ssl_pinning_plugin.dart';
  
Version Uploaded Documentation Archive
0.0.1 May 29, 2018 Go to the documentation of ssl_pinning_plugin 0.0.1 Download ssl_pinning_plugin 0.0.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
72 / 100
Overall score:
Weighted score of the above. [more]
43
Learn more about scoring.

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Suggestions

  • Fix dependencies in pubspec.yaml.

    Running flutter packages pub upgrade failed with the following output:

    ERR: The current Flutter SDK version is 0.5.4.
     
     Because ssl_pinning_plugin requires Flutter SDK version ^0.4.4, version solving failed.
    
  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Fix dependencies in pubspec.yaml.

  • Running dartdoc failed.

    Make sure dartdoc runs without any issues.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/ssl_pinning_plugin.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0