Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check certificate while sending and receiving data #3

Open
mleonhard opened this issue Sep 26, 2019 · 8 comments
Open

Check certificate while sending and receiving data #3

mleonhard opened this issue Sep 26, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@mleonhard
Copy link

My dartlang application performs network requests like this:

Future<List<int>> streamToBytes(Stream<List<int>> stream) => stream
        .fold(new BytesBuilder(), (BytesBuilder bytesBuilder, List<int> bytes) {
      bytesBuilder.add(bytes);
      return bytesBuilder;
    }).then((BytesBuilder bytesBuilder) => bytesBuilder.takeBytes());

final HttpClient client = new HttpClient();
Map<String, String> headers = Map.from(headers);
final HttpClientRequest request = await client.postUrl(url);
request.headers.set('user-agent', userAgent));
request.headers.contentLength = bytes.length;
request.add(bytes);
final HttpClientResponse response = await request.close();
final List<int> bytes = await streamToBytes(response);
return new HttpResponse(response.statusCode, response.reasonPhrase,
        response.headers.value(HttpHeaders.contentTypeHeader) ?? '', bytes);

Please add a way to check the certificate used by such requests, to protect the data sent and received by the app.

@smian-esba
Copy link

Hi @us3soap, thank you for creating an awesome plugin. We are looking forward to using this but this issue mentioned above is holding us back. Please let me know what would it take to add "certificate check" into the plugin so we safely implement cert pinning through this plugin. Thanks very much for your contribution!

@us3soap
Copy link
Member

us3soap commented Mar 9, 2020

Hi, sorry for the delay.

Do you need support or evolution ?

@sahil-oyo
Copy link

As mentioned by @mleonhard in this thread, i guess the plugin makes a separate call to same domain for validating the keys.

Therefore, two calls are being made for every request where we need SSL pinning. It would be really nice if we can validate Certificate Key in the original request itself.

@basnetjiten
Copy link

basnetjiten commented Apr 24, 2020

@SahilPatel16 do we have anything alternative to these solution. I found this code in stackoverflow

HttpClient client = new HttpClient();
client.badCertificateCallback = ((X509Certificate cert, String host, int port) {
final isValidHost = host == "api.my_app";
return isValidHost;
});
what is this host checking here can anyone explains it.

@sahil-oyo
Copy link

There is inbuilt support for SSL pinning in dart but it does not cover all the cases. A possible alternative would be to get inbuilt support fixed.

Checkout this and this


HttpClient client = new HttpClient();
client.badCertificateCallback = ((X509Certificate cert, String host, int port) {
final isValidHost = host == "api.my_app";
return isValidHost;
});
what is this host checking here can anyone explains it.

In the code snippet you are checking if the request is coming from the desired host. I am not sure about your use case but this does not help us with MITM attacks.

@us3soap us3soap added the enhancement New feature or request label Jul 11, 2020
@bkhezry
Copy link

bkhezry commented Dec 10, 2020

Any update?

@akrmr
Copy link

akrmr commented Jul 7, 2021

Bump! Any update on this issue?

@shubhamhackz
Copy link

It's been three years since this was opened, let us know if there's any update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants