Skip to content

CERTIFICATE_VERIFY_FAILED #267

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
familfamilzade opened this issue Apr 12, 2019 · 8 comments
Closed

CERTIFICATE_VERIFY_FAILED #267

familfamilzade opened this issue Apr 12, 2019 · 8 comments

Comments

@familfamilzade
Copy link

Is there any way to use badCertificateCallback with this package? I am using an api for get/post requests and it throws error "CERTIFICATE_VERIFY_FAILED" when I use http package post or get method, but when HttpClient is used with badCertificateCallback method set to true api responds properly. How can I use http package for the same request?

The way that is reminded in #14 is not available in the last versions of related package.

@natebosch
Copy link
Member

Construct an HttpClient from dart:io using the options you are interested in. Pass it to IOClient(httpClient) to wrap it as a a Client from this package.

@duzenko
Copy link

duzenko commented May 8, 2019

Like this?

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

    final ioc = new HttpClient();
    ioc.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
    final http = new IOClient(ioc);

@natebosch
Copy link
Member

@duzenko - looks about right.

@zhenalexfan
Copy link

Construct an HttpClient from dart:io using the options you are interested in. Pass it to IOClient(httpClient) to wrap it as a a Client from this package.

Like this?

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

    final ioc = new HttpClient();
    ioc.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
    final http = new IOClient(ioc);

I tried this and am still getting CERTIFICATE_VERIFY_FAILED. Any suggestions?

@natebosch
Copy link
Member

I tried this and am still getting CERTIFICATE_VERIFY_FAILED. Any suggestions?

You might ask for help on stack overflow, or if you think there is a bug in the dart:io HttpClient class you can file an issue on the SDK repo.

@duzenko
Copy link

duzenko commented Oct 24, 2019

@alexfanchina
Please attach a complete repro case

@funkju
Copy link

funkju commented Apr 20, 2020

Could you share some example code for how to tell a request object (like MultiPartRequest) to use the constructed IOClient?

EDIT

It's actually pretty obvious - for everyone who comes looking here:

Instead of sending from your Request object like req.send(...);

Send the Request object through your constructed IOClient like ioClient.send(req)

@mehrdadmmb2
Copy link

Like this?

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

    final ioc = new HttpClient();
    ioc.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
    final http = new IOClient(ioc);

final http = new IOClient(ioc);// userful line

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

6 participants