Skip to content

Handshake error #11

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

Closed
alamboley opened this issue Jul 16, 2020 · 4 comments
Closed

Handshake error #11

alamboley opened this issue Jul 16, 2020 · 4 comments

Comments

@alamboley
Copy link

Hello,

When making a xml_rpc call on Android I got:

I/flutter (14243): HandshakeException: Handshake error in client (OS Error: 
I/flutter (14243): 	CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354))

I added Android Internet permission https://flutter.dev/docs/development/data-and-backend/networking#android but without luck.

It seems this is a common issue, a way to resolve this is:

HttpClient client = new HttpClient();
client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true);

Is there a way to give this client to xml_rpc plugin?

@a14n
Copy link
Owner

a14n commented Jul 16, 2020

You can provide your own httpPost parameter to the call method.

@a14n a14n closed this as completed Jul 16, 2020
@gsynuh
Copy link

gsynuh commented Jul 21, 2020

@alamboley
@a14n

Hi ! though this issue is closed, you might be familiar enough with the subject to guide me?

I have had the same problem basically, I tried creating a HttpClient (from the same package as mentioned above), I tried passing client.post to the httpPost argument of xml_rpc's call function.

It seems that they expect different types of return types , both Future but HttpResponse vs HttpClientRequest .

So I have no idea where to start with providing my own httpPost here (I was hoping to pass in the dart.io package's HttpClient

Here's an old solution only mentioning the http package :
dart-lang/http#14 (comment)

Though I do not know either how to set this one up.

So, can httpPost actually reference a post function from the dart:io 's HttpClient - or is there a clear more obvious way I'm missing for xml_rpc to use the dart:io's http stuff either directly or indirectly just so the certificates are ignored.

Thank you in advance for any kind of tips or information that could guide me further, even if it is to actually modify the contents of the packages themselves on my local copy - I won't mind at this point.

@a14n
Copy link
Owner

a14n commented Jul 21, 2020

dart-xmlrpc doesn't use directly dart:io because dart:io is not available in browser. That's why the httpPost mentioned above has the same signature as package:http BaseClient.post.

So the following code should work (not tested and only where dart:io is available):

import 'dart:io' as io;
import 'package:http/http.dart' as http;

final ioClient = io.HttpClient()
  ..badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
final httpPost = http.IOClient(ioClient).post;
xml_rpc.call(url, methodName, params, httpPost: httpPost);

@gsynuh
Copy link

gsynuh commented Jul 22, 2020

@a14n

thank you!

It appears to work fine now after testing!

The slight difference to your code is that IOClient seems to have been seperated from the http package for some reason ? Anyway I found that importing http/io_client.dart fixed that issue instead of the full http package

import 'dart:io' as io;
import 'package:http/io_client.dart';

  final ioClient = io.HttpClient()
    ..badCertificateCallback = ((io.X509Certificate cert, String host, int port) => true);
  final httpPost = IOClient(ioClient).post;

//then use httpPost as httpPost in xml_rpc.call( ...

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

No branches or pull requests

3 participants